diff --git a/stormpy/MANIFEST.in b/stormpy/MANIFEST.in new file mode 100644 index 000000000..0e6f51f28 --- /dev/null +++ b/stormpy/MANIFEST.in @@ -0,0 +1 @@ +recursive-include src *.h diff --git a/stormpy/lib/.gitignore b/stormpy/lib/.gitignore new file mode 100644 index 000000000..c70bcf8ef --- /dev/null +++ b/stormpy/lib/.gitignore @@ -0,0 +1,3 @@ +*.so +__pycache__/ +stormpy.egg-info/ diff --git a/stormpy/lib/stormpy/__init__.py b/stormpy/lib/stormpy/__init__.py new file mode 100644 index 000000000..ca45a2d36 --- /dev/null +++ b/stormpy/lib/stormpy/__init__.py @@ -0,0 +1,2 @@ +from . import core +from .core import * diff --git a/stormpy/lib/stormpy/info/__init__.py b/stormpy/lib/stormpy/info/__init__.py new file mode 100644 index 000000000..d8e3cfa68 --- /dev/null +++ b/stormpy/lib/stormpy/info/__init__.py @@ -0,0 +1,2 @@ +from . import info +from .info import * diff --git a/stormpy/resources/pybind11/.appveyor.yml b/stormpy/resources/pybind11/.appveyor.yml new file mode 100644 index 000000000..5e283af1e --- /dev/null +++ b/stormpy/resources/pybind11/.appveyor.yml @@ -0,0 +1,26 @@ +version: 1.0.{build} +os: Visual Studio 2015 +clone_folder: C:\projects\pybind11 +test: off +configuration: + - Release + - Debug +branches: + only: + - master +environment: + matrix: + - CMAKE_PLATFORM: "Visual Studio 14 2015" + PYTHON_DIR: "C:\\Python34" + - CMAKE_PLATFORM: "Visual Studio 14 2015 Win64" + PYTHON_DIR: "C:\\Python34-x64" +install: + - cinstall: python +build_script: + - echo Running cmake... + - cd c:\projects\pybind11 + - cmake -G "%CMAKE_PLATFORM%" -DPYTHON_INCLUDE_DIR:PATH=%PYTHON_DIR%/include -DPYTHON_LIBRARY:FILEPATH=%PYTHON_DIR%/libs/python34.lib -DPYTHON_EXECUTABLE:FILEPATH=%PYTHON_DIR%/python.exe + - set MSBuildLogger="C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" + - set MSBuildOptions=/v:m /p:Configuration=%Configuration% /logger:%MSBuildLogger% + - msbuild %MSBuildOptions% pybind11.sln + - ctest -C %Configuration% diff --git a/stormpy/resources/pybind11/.gitignore b/stormpy/resources/pybind11/.gitignore new file mode 100644 index 000000000..a7a49560d --- /dev/null +++ b/stormpy/resources/pybind11/.gitignore @@ -0,0 +1,31 @@ +CMakeCache.txt +CMakeFiles +Makefile +cmake_install.cmake +.DS_Store +/example/example.so +/example/example.pyd +*.sln +*.sdf +*.opensdf +*.vcxproj +*.filters +example.dir +Win32 +x64 +Release +Debug +.vs +CTestTestfile.cmake +Testing +autogen +MANIFEST +/.ninja_* +/*.ninja +/docs/.build +*.py[co] +*.egg-info +*~ +.DS_Store +/dist +/build diff --git a/stormpy/resources/pybind11/.gitmodules b/stormpy/resources/pybind11/.gitmodules new file mode 100644 index 000000000..5191885e7 --- /dev/null +++ b/stormpy/resources/pybind11/.gitmodules @@ -0,0 +1,3 @@ +[submodule "tools/clang"] + path = tools/clang + url = https://github.com/wjakob/clang-cindex-python3 diff --git a/stormpy/resources/pybind11/.travis.yml b/stormpy/resources/pybind11/.travis.yml new file mode 100644 index 000000000..9a9088fa8 --- /dev/null +++ b/stormpy/resources/pybind11/.travis.yml @@ -0,0 +1,41 @@ +language: cpp +sudo: false +cache: + directories: + - $HOME/.cache/pip +addons: + apt: + sources: + - ubuntu-toolchain-r-test + - deadsnakes + packages: + - g++-4.8 + - g++-4.8-multilib + - g++-multilib + - python3.5 + - python3.5-dev + - python3.5-venv + - python3.5-dev:i386 +matrix: + include: + - os: linux + compiler: gcc-4.8 + script: + - pyvenv-3.5 venv + - cmake -DPYBIND11_PYTHON_VERSION=3.5 -DPYTHON_INCLUDE_DIR:PATH=/usr/include/python3.5m -DPYTHON_LIBRARY:FILEPATH=/usr/lib/x86_64-linux-gnu/libpython3.5m.so -DPYTHON_EXECUTABLE:FILEPATH=`pwd`/venv/bin/python3.5 -DCMAKE_CXX_COMPILER=g++-4.8 + - make -j 2 + - source venv/bin/activate + - pip install numpy + - CTEST_OUTPUT_ON_FAILURE=TRUE make test + - os: osx + compiler: clang + script: + - cmake -DPYBIND11_PYTHON_VERSION=2.7 + - make -j 2 + - CTEST_OUTPUT_ON_FAILURE=TRUE make test + #- os: linux + #compiler: gcc-4.8 + #script: + #- pyvenv-3.5 venv + #- cmake -DPYBIND11_PYTHON_VERSION=3.5 -DPYTHON_INCLUDE_DIR:PATH=/usr/include/python3.5m -DPYTHON_LIBRARY:FILEPATH=/usr/lib/x86_64-linux-gnu/libpython3.5m.so -DPYTHON_EXECUTABLE:FILEPATH=`pwd`/venv/bin/python3.5 -DCMAKE_CXX_COMPILER=g++-4.8 -DCMAKE_CXX_FLAGS=-m32 + #- make -j 2 diff --git a/stormpy/resources/pybind11/CMakeLists.txt b/stormpy/resources/pybind11/CMakeLists.txt new file mode 100644 index 000000000..2996e537b --- /dev/null +++ b/stormpy/resources/pybind11/CMakeLists.txt @@ -0,0 +1,220 @@ +# CMakeLists.txt -- Build system for the pybind11 examples +# +# Copyright (c) 2015 Wenzel Jakob <wenzel@inf.ethz.ch> +# +# All rights reserved. Use of this source code is governed by a +# BSD-style license that can be found in the LICENSE file. + +cmake_minimum_required(VERSION 2.8) + +project(pybind11) + +option(PYBIND11_INSTALL "Install pybind11 header files?" ON) + +# Add a CMake parameter for choosing a desired Python version +set(PYBIND11_PYTHON_VERSION "" CACHE STRING "Python version to use for compiling the example application") + +include(CheckCXXCompilerFlag) + +# Set a default build configuration if none is specified. 'MinSizeRel' produces the smallest binaries +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + message(STATUS "Setting build type to 'MinSizeRel' as none was specified.") + set(CMAKE_BUILD_TYPE MinSizeRel CACHE STRING "Choose the type of build." FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" + "MinSizeRel" "RelWithDebInfo") +endif() +string(TOUPPER "${CMAKE_BUILD_TYPE}" U_CMAKE_BUILD_TYPE) + +set(Python_ADDITIONAL_VERSIONS 3.4 3.5 3.6 3.7) +if (NOT ${PYBIND11_PYTHON_VERSION} STREQUAL "") + find_package(PythonLibs ${PYBIND11_PYTHON_VERSION} EXACT) + if (NOT PythonLibs_FOUND) + find_package(PythonLibs ${PYBIND11_PYTHON_VERSION} REQUIRED) + endif() +else() + find_package(PythonLibs REQUIRED) +endif() +# The above sometimes returns version numbers like "3.4.3+"; the "+" must be removed for the next line to work +string(REPLACE "+" "" PYTHONLIBS_VERSION_STRING "+${PYTHONLIBS_VERSION_STRING}") +find_package(PythonInterp ${PYTHONLIBS_VERSION_STRING} EXACT REQUIRED) + +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel") + CHECK_CXX_COMPILER_FLAG("-std=c++14" HAS_CPP14_FLAG) + CHECK_CXX_COMPILER_FLAG("-std=c++11" HAS_CPP11_FLAG) + + if (HAS_CPP14_FLAG) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") + elseif (HAS_CPP11_FLAG) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + else() + message(FATAL_ERROR "Unsupported compiler -- pybind11 requires C++11 support!") + endif() + + # Enable link time optimization and set the default symbol + # visibility to hidden (very important to obtain small binaries) + if (NOT ${U_CMAKE_BUILD_TYPE} MATCHES DEBUG) + # Default symbol visibility + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") + + # Check for Link Time Optimization support + # (GCC/Clang) + CHECK_CXX_COMPILER_FLAG("-flto" HAS_LTO_FLAG) + if (HAS_LTO_FLAG) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto") + endif() + + # Intel equivalent to LTO is called IPO + if (CMAKE_CXX_COMPILER_ID MATCHES "Intel") + CHECK_CXX_COMPILER_FLAG("-ipo" HAS_IPO_FLAG) + if (HAS_IPO_FLAG) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ipo") + endif() + endif() + endif() +endif() + +# Compile with compiler warnings turned on +if(MSVC) + if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]") + string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4") + endif() +elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra") +endif() + +# Include path for Python header files +include_directories(${PYTHON_INCLUDE_DIR}) + +# Include path for pybind11 header files +include_directories(include) + +set(PYBIND11_HEADERS + include/pybind11/attr.h + include/pybind11/cast.h + include/pybind11/common.h + include/pybind11/complex.h + include/pybind11/descr.h + include/pybind11/functional.h + include/pybind11/numpy.h + include/pybind11/operators.h + include/pybind11/pybind11.h + include/pybind11/pytypes.h + include/pybind11/stl.h + include/pybind11/typeid.h +) + +set(PYBIND11_EXAMPLES + example/example1.cpp + example/example2.cpp + example/example3.cpp + example/example4.cpp + example/example5.cpp + example/example6.cpp + example/example7.cpp + example/example8.cpp + example/example9.cpp + example/example10.cpp + example/example11.cpp + example/example12.cpp + example/example13.cpp + example/example14.cpp + example/example15.cpp + example/example16.cpp + example/issues.cpp +) + +# Create the binding library +add_library(example SHARED + ${PYBIND11_HEADERS} + example/example.cpp + ${PYBIND11_EXAMPLES} +) + +# Don't add a 'lib' prefix to the shared library +set_target_properties(example PROPERTIES PREFIX "") + +# Always write the output file directly into the 'example' directory (even on MSVC) +set(CompilerFlags + LIBRARY_OUTPUT_DIRECTORY LIBRARY_OUTPUT_DIRECTORY_RELEASE LIBRARY_OUTPUT_DIRECTORY_DEBUG + LIBRARY_OUTPUT_DIRECTORY_MINSIZEREL LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO + RUNTIME_OUTPUT_DIRECTORY RUNTIME_OUTPUT_DIRECTORY_RELEASE RUNTIME_OUTPUT_DIRECTORY_DEBUG + RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO) + +foreach(CompilerFlag ${CompilerFlags}) + set_target_properties(example PROPERTIES ${CompilerFlag} ${PROJECT_SOURCE_DIR}/example) +endforeach() + +if (WIN32) + if (MSVC) + # /bigobj is needed for bigger binding projects due to the limit to 64k + # addressable sections. /MP enables multithreaded builds (relevant when + # there are many files). + set_target_properties(example PROPERTIES COMPILE_FLAGS "/MP /bigobj ") + + if (NOT ${U_CMAKE_BUILD_TYPE} MATCHES DEBUG) + # Enforce size-based optimization and link time code generation on MSVC + # (~30% smaller binaries in experiments). + set_target_properties(example APPEND_STRING PROPERTY COMPILE_FLAGS "/Os /GL ") + set_target_properties(example APPEND_STRING PROPERTY LINK_FLAGS "/LTCG ") + endif() + endif() + + # .PYD file extension on Windows + set_target_properties(example PROPERTIES SUFFIX ".pyd") + + # Link against the Python shared library + target_link_libraries(example ${PYTHON_LIBRARY}) +elseif (UNIX) + # It's quite common to have multiple copies of the same Python version + # installed on one's system. E.g.: one copy from the OS and another copy + # that's statically linked into an application like Blender or Maya. + # If we link our plugin library against the OS Python here and import it + # into Blender or Maya later on, this will cause segfaults when multiple + # conflicting Python instances are active at the same time (even when they + # are of the same version). + + # Windows is not affected by this issue since it handles DLL imports + # differently. The solution for Linux and Mac OS is simple: we just don't + # link against the Python library. The resulting shared library will have + # missing symbols, but that's perfectly fine -- they will be resolved at + # import time. + + # .SO file extension on Linux/Mac OS + set_target_properties(example PROPERTIES SUFFIX ".so") + + # Optimize for a small binary size + if (NOT ${U_CMAKE_BUILD_TYPE} MATCHES DEBUG) + set_target_properties(example PROPERTIES COMPILE_FLAGS "-Os") + endif() + + # Strip unnecessary sections of the binary on Linux/Mac OS + if(APPLE) + set_target_properties(example PROPERTIES MACOSX_RPATH ".") + set_target_properties(example PROPERTIES LINK_FLAGS "-undefined dynamic_lookup ") + if (NOT ${U_CMAKE_BUILD_TYPE} MATCHES DEBUG) + add_custom_command(TARGET example POST_BUILD COMMAND strip -u -r ${PROJECT_SOURCE_DIR}/example/example.so) + endif() + else() + if (NOT ${U_CMAKE_BUILD_TYPE} MATCHES DEBUG) + add_custom_command(TARGET example POST_BUILD COMMAND strip ${PROJECT_SOURCE_DIR}/example/example.so) + endif() + endif() +endif() + +enable_testing() + +set(RUN_TEST ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/example/run_test.py) +if (MSVC OR CMAKE_CXX_COMPILER_ID MATCHES "Intel") + set(RUN_TEST ${RUN_TEST} --relaxed) +endif() + +foreach(VALUE ${PYBIND11_EXAMPLES}) + string(REGEX REPLACE "^example/(.+).cpp$" "\\1" EXAMPLE_NAME "${VALUE}") + add_test(NAME ${EXAMPLE_NAME} COMMAND ${RUN_TEST} ${EXAMPLE_NAME}) +endforeach() + +if (PYBIND11_INSTALL) + install(FILES ${PYBIND11_HEADERS} DESTINATION include/pybind11) +endif() diff --git a/stormpy/resources/pybind11/CONTRIBUTING.md b/stormpy/resources/pybind11/CONTRIBUTING.md new file mode 100644 index 000000000..d700c4ae7 --- /dev/null +++ b/stormpy/resources/pybind11/CONTRIBUTING.md @@ -0,0 +1,37 @@ +Thank you for your interest in this project! Please refer to the following +sections on how to contribute code and bug reports. + +### Reporting bugs + +At the moment, this project is run in the spare time of a single person +([Wenzel Jakob](http://rgl.epfl.ch/people/wjakob)) with very limited resources +for issue tracker tickets. Thus, before submitting a question or bug report, +please take a moment of your time and ensure that your issue isn't already +discussed in the project documentation provided at +[http://pybind11.readthedocs.org/en/latest](http://pybind11.readthedocs.org/en/latest). + +Assuming that you have identified a previously unknown problem or an important +question, it's essential that you submit a self-contained and minimal piece of +code that reproduces the problem. In other words: no external dependencies, +isolate the function(s) that cause breakage, submit matched and complete C++ +and Python snippets that can be easily compiled and run on my end. + +## Pull requests +Contributions are submitted, reviewed, and accepted using Github pull requests. +Please refer to [this +article](https://help.github.com/articles/using-pull-requests) for details and +adhere to the following rules to make the process as smooth as possible: + +* Make a new branch for every feature you're working on. +* Make small and clean pull requests that are easy to review but make sure they + do add value by themselves. +* Add tests for any new functionality and run the test suite (``make test``) to + ensure that no existing features break. +* This project has a strong focus on providing general solutions using a + minimal amount of code, thus small pull requests are greatly preferred. + +### License + +pybind11 is provided under a BSD-style license that can be found in the +``LICENSE`` file. By using, distributing, or contributing to this project, you +agree to the terms and conditions of this license. diff --git a/stormpy/resources/pybind11/LICENSE b/stormpy/resources/pybind11/LICENSE new file mode 100644 index 000000000..d134ff5bc --- /dev/null +++ b/stormpy/resources/pybind11/LICENSE @@ -0,0 +1,36 @@ +Copyright (c) 2015 Wenzel Jakob <wenzel@inf.ethz.ch>, All rights reserved. + +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. + +You are under no obligation whatsoever to provide any bug fixes, patches, or +upgrades to the features, functionality or performance of the source code +("Enhancements") to anyone; however, if you choose to make your Enhancements +available either publicly, or directly to the author of this software, without +imposing a separate written license agreement for such Enhancements, then you +hereby grant the following license: a non-exclusive, royalty-free perpetual +license to install, use, modify, prepare derivative works, incorporate into +other computer software, distribute, and sublicense such enhancements or +derivative works thereof, in binary and source code form. diff --git a/stormpy/resources/pybind11/MANIFEST.in b/stormpy/resources/pybind11/MANIFEST.in new file mode 100644 index 000000000..33c22c84c --- /dev/null +++ b/stormpy/resources/pybind11/MANIFEST.in @@ -0,0 +1 @@ +include include/pybind11/*.h diff --git a/stormpy/resources/pybind11/README.md b/stormpy/resources/pybind11/README.md new file mode 100644 index 000000000..baefb2baf --- /dev/null +++ b/stormpy/resources/pybind11/README.md @@ -0,0 +1,108 @@ + + +# pybind11 — Seamless operability between C++11 and Python + +[](http://pybind11.readthedocs.org/en/latest/?badge=latest) +[](https://travis-ci.org/pybind/pybind11) +[](https://ci.appveyor.com/project/wjakob/pybind11) + +**pybind11** is a lightweight header-only library that exposes C++ types in Python +and vice versa, mainly to create Python bindings of existing C++ code. Its +goals and syntax are similar to the excellent +[Boost.Python](http://www.boost.org/doc/libs/1_58_0/libs/python/doc/) library +by David Abrahams: to minimize boilerplate code in traditional extension +modules by inferring type information using compile-time introspection. + +The main issue with Boost.Python—and the reason for creating such a similar +project—is Boost. Boost is an enormously large and complex suite of utility +libraries that works with almost every C++ compiler in existence. This +compatibility has its cost: arcane template tricks and workarounds are +necessary to support the oldest and buggiest of compiler specimens. Now that +C++11-compatible compilers are widely available, this heavy machinery has +become an excessively large and unnecessary dependency. + +Think of this library as a tiny self-contained version of Boost.Python with +everything stripped away that isn't relevant for binding generation. Without +comments, the core header files only require ~2.5K lines of code and depend on +Python (2.7 or 3.x) and the C++ standard library. This compact implementation +was possible thanks to some of the new C++11 language features (specifically: +tuples, lambda functions and variadic templates). Since its creation, this +library has grown beyond Boost.Python in many ways, leading to dramatically +simpler binding code in many common situations. + +Tutorial and reference documentation is provided at +[http://pybind11.readthedocs.org/en/latest](http://pybind11.readthedocs.org/en/latest). + +## Core features +pybind11 can map the following core C++ features to Python + +- Functions accepting and returning custom data structures per value, reference, or pointer +- Instance methods and static methods +- Overloaded functions +- Instance attributes and static attributes +- Exceptions +- Enumerations +- Callbacks +- Custom operators +- STL data structures +- Iterators and ranges +- Smart pointers with reference counting like `std::shared_ptr` +- Internal references with correct reference counting +- C++ classes with virtual (and pure virtual) methods can be extended in Python + +## Goodies +In addition to the core functionality, pybind11 provides some extra goodies: + +- pybind11 uses C++11 move constructors and move assignment operators whenever + possible to efficiently transfer custom data types. + +- It is possible to bind C++11 lambda functions with captured variables. The + lambda capture data is stored inside the resulting Python function object. + +- It's easy to expose the internal storage of custom data types through + Pythons' buffer protocols. This is handy e.g. for fast conversion between + C++ matrix classes like Eigen and NumPy without expensive copy operations. + +- pybind11 can automatically vectorize functions so that they are transparently + applied to all entries of one or more NumPy array arguments. + +- Python's slice-based access and assignment operations can be supported with + just a few lines of code. + +- Everything is contained in just a few header files; there is no need to link + against any additional libraries. + +- Binaries are generally smaller by a factor of 2 or more compared to + equivalent bindings generated by Boost.Python. + +- When supported by the compiler, two new C++14 features (relaxed constexpr and + return value deduction) are used to precompute function signatures at compile + time, leading to smaller binaries. + +- With little extra effort, C++ types can be pickled and unpickled similar to + regular Python objects. + +## Supported compilers + +1. Clang/LLVM (any non-ancient version with C++11 support) +2. GCC (any non-ancient version with C++11 support) +3. Microsoft Visual Studio 2015 or newer +4. Intel C++ compiler v15 or newer + +## About + +This project was created by [Wenzel Jakob](https://www.mitsuba-renderer.org/~wenzel/). +Significant features and/or improvements to the code were contributed by +Jonas Adler, +Sylvain Corlay, +Axel Huebl, +@hulucc, +Johan Mabille, +Tomasz Miąsko, and +Ben Pritchard. + +### License + +pybind11 is provided under a BSD-style license that can be found in the +``LICENSE`` file. By using, distributing, or contributing to this project, +you agree to the terms and conditions of this license. diff --git a/stormpy/resources/pybind11/conda.recipe/bld.bat b/stormpy/resources/pybind11/conda.recipe/bld.bat new file mode 100644 index 000000000..b9cd616ce --- /dev/null +++ b/stormpy/resources/pybind11/conda.recipe/bld.bat @@ -0,0 +1,2 @@ +"%PYTHON%" setup.py install --single-version-externally-managed --record=record.txt +if errorlevel 1 exit 1 diff --git a/stormpy/resources/pybind11/conda.recipe/build.sh b/stormpy/resources/pybind11/conda.recipe/build.sh new file mode 100644 index 000000000..175d6f16e --- /dev/null +++ b/stormpy/resources/pybind11/conda.recipe/build.sh @@ -0,0 +1,3 @@ +#!/bin/bash +${PYTHON} setup.py install --single-version-externally-managed --record=record.txt; + diff --git a/stormpy/resources/pybind11/conda.recipe/meta.yaml b/stormpy/resources/pybind11/conda.recipe/meta.yaml new file mode 100644 index 000000000..fbbb830b7 --- /dev/null +++ b/stormpy/resources/pybind11/conda.recipe/meta.yaml @@ -0,0 +1,26 @@ +package: + name: pybind11 + version: {{ environ.get('GIT_DESCRIBE_TAG', '').replace('v', '') }} + +build: + number: {{ environ.get('GIT_DESCRIBE_NUMBER', 0) }} + {% if environ.get('GIT_DESCRIBE_NUMBER', '0') == '0' %}string: py{{ environ.get('PY_VER').replace('.', '') }}_0 + {% else %}string: py{{ environ.get('PY_VER').replace('.', '') }}_{{ environ.get('GIT_BUILD_STR', 'GIT_STUB') }}{% endif %} + +source: + git_url: ../ + +requirements: + build: + - python + + run: + - python + +test: + imports: + - pybind11 + +about: + home: https://github.com/pybind/pybind11/ + summary: Seamless operability between C++11 and Python diff --git a/stormpy/resources/pybind11/docs/_static/theme_overrides.css b/stormpy/resources/pybind11/docs/_static/theme_overrides.css new file mode 100644 index 000000000..f678ab548 --- /dev/null +++ b/stormpy/resources/pybind11/docs/_static/theme_overrides.css @@ -0,0 +1,7 @@ +.wy-table-responsive table td, +.wy-table-responsive table th { + white-space: initial !important; +} +.rst-content table.docutils td { + vertical-align: top !important; +} diff --git a/stormpy/resources/pybind11/docs/advanced.rst b/stormpy/resources/pybind11/docs/advanced.rst new file mode 100644 index 000000000..9df5cb3fe --- /dev/null +++ b/stormpy/resources/pybind11/docs/advanced.rst @@ -0,0 +1,1299 @@ +.. _advanced: + +Advanced topics +############### + +For brevity, the rest of this chapter assumes that the following two lines are +present: + +.. code-block:: cpp + + #include <pybind11/pybind11.h> + + namespace py = pybind11; + +Exporting constants and mutable objects +======================================= + +To expose a C++ constant, use the ``attr`` function to register it in a module +as shown below. The ``int_`` class is one of many small wrapper objects defined +in ``pybind11/pytypes.h``. General objects (including integers) can also be +converted using the function ``cast``. + +.. code-block:: cpp + + PYBIND11_PLUGIN(example) { + py::module m("example", "pybind11 example plugin"); + m.attr("MY_CONSTANT") = py::int_(123); + m.attr("MY_CONSTANT_2") = py::cast(new MyObject()); + } + +Operator overloading +==================== + +Suppose that we're given the following ``Vector2`` class with a vector addition +and scalar multiplication operation, all implemented using overloaded operators +in C++. + +.. code-block:: cpp + + class Vector2 { + public: + Vector2(float x, float y) : x(x), y(y) { } + + std::string toString() const { return "[" + std::to_string(x) + ", " + std::to_string(y) + "]"; } + + Vector2 operator+(const Vector2 &v) const { return Vector2(x + v.x, y + v.y); } + Vector2 operator*(float value) const { return Vector2(x * value, y * value); } + Vector2& operator+=(const Vector2 &v) { x += v.x; y += v.y; return *this; } + Vector2& operator*=(float v) { x *= v; y *= v; return *this; } + + friend Vector2 operator*(float f, const Vector2 &v) { return Vector2(f * v.x, f * v.y); } + + private: + float x, y; + }; + +The following snippet shows how the above operators can be conveniently exposed +to Python. + +.. code-block:: cpp + + #include <pybind11/operators.h> + + PYBIND11_PLUGIN(example) { + py::module m("example", "pybind11 example plugin"); + + py::class_<Vector2>(m, "Vector2") + .def(py::init<float, float>()) + .def(py::self + py::self) + .def(py::self += py::self) + .def(py::self *= float()) + .def(float() * py::self) + .def("__repr__", &Vector2::toString); + + return m.ptr(); + } + +Note that a line like + +.. code-block:: cpp + + .def(py::self * float()) + +is really just short hand notation for + +.. code-block:: cpp + + .def("__mul__", [](const Vector2 &a, float b) { + return a * b; + }) + +This can be useful for exposing additional operators that don't exist on the +C++ side, or to perform other types of customization. + +.. note:: + + To use the more convenient ``py::self`` notation, the additional + header file :file:`pybind11/operators.h` must be included. + +.. seealso:: + + The file :file:`example/example3.cpp` contains a complete example that + demonstrates how to work with overloaded operators in more detail. + +Callbacks and passing anonymous functions +========================================= + +The C++11 standard brought lambda functions and the generic polymorphic +function wrapper ``std::function<>`` to the C++ programming language, which +enable powerful new ways of working with functions. Lambda functions come in +two flavors: stateless lambda function resemble classic function pointers that +link to an anonymous piece of code, while stateful lambda functions +additionally depend on captured variables that are stored in an anonymous +*lambda closure object*. + +Here is a simple example of a C++ function that takes an arbitrary function +(stateful or stateless) with signature ``int -> int`` as an argument and runs +it with the value 10. + +.. code-block:: cpp + + int func_arg(const std::function<int(int)> &f) { + return f(10); + } + +The example below is more involved: it takes a function of signature ``int -> int`` +and returns another function of the same kind. The return value is a stateful +lambda function, which stores the value ``f`` in the capture object and adds 1 to +its return value upon execution. + +.. code-block:: cpp + + std::function<int(int)> func_ret(const std::function<int(int)> &f) { + return [f](int i) { + return f(i) + 1; + }; + } + +After including the extra header file :file:`pybind11/functional.h`, it is almost +trivial to generate binding code for both of these functions. + +.. code-block:: cpp + + #include <pybind11/functional.h> + + PYBIND11_PLUGIN(example) { + py::module m("example", "pybind11 example plugin"); + + m.def("func_arg", &func_arg); + m.def("func_ret", &func_ret); + + return m.ptr(); + } + +The following interactive session shows how to call them from Python. + +.. code-block:: python + + $ python + >>> import example + >>> def square(i): + ... return i * i + ... + >>> example.func_arg(square) + 100L + >>> square_plus_1 = example.func_ret(square) + >>> square_plus_1(4) + 17L + >>> + +.. note:: + + This functionality is very useful when generating bindings for callbacks in + C++ libraries (e.g. a graphical user interface library). + + The file :file:`example/example5.cpp` contains a complete example that + demonstrates how to work with callbacks and anonymous functions in more detail. + +.. warning:: + + Keep in mind that passing a function from C++ to Python (or vice versa) + will instantiate a piece of wrapper code that translates function + invocations between the two languages. Copying the same function back and + forth between Python and C++ many times in a row will cause these wrappers + to accumulate, which can decrease performance. + +Overriding virtual functions in Python +====================================== + +Suppose that a C++ class or interface has a virtual function that we'd like to +to override from within Python (we'll focus on the class ``Animal``; ``Dog`` is +given as a specific example of how one would do this with traditional C++ +code). + +.. code-block:: cpp + + class Animal { + public: + virtual ~Animal() { } + virtual std::string go(int n_times) = 0; + }; + + class Dog : public Animal { + public: + std::string go(int n_times) { + std::string result; + for (int i=0; i<n_times; ++i) + result += "woof! "; + return result; + } + }; + +Let's also suppose that we are given a plain function which calls the +function ``go()`` on an arbitrary ``Animal`` instance. + +.. code-block:: cpp + + std::string call_go(Animal *animal) { + return animal->go(3); + } + +Normally, the binding code for these classes would look as follows: + +.. code-block:: cpp + + PYBIND11_PLUGIN(example) { + py::module m("example", "pybind11 example plugin"); + + py::class_<Animal> animal(m, "Animal"); + animal + .def("go", &Animal::go); + + py::class_<Dog>(m, "Dog", animal) + .def(py::init<>()); + + m.def("call_go", &call_go); + + return m.ptr(); + } + +However, these bindings are impossible to extend: ``Animal`` is not +constructible, and we clearly require some kind of "trampoline" that +redirects virtual calls back to Python. + +Defining a new type of ``Animal`` from within Python is possible but requires a +helper class that is defined as follows: + +.. code-block:: cpp + + class PyAnimal : public Animal { + public: + /* Inherit the constructors */ + using Animal::Animal; + + /* Trampoline (need one for each virtual function) */ + std::string go(int n_times) { + PYBIND11_OVERLOAD_PURE( + std::string, /* Return type */ + Animal, /* Parent class */ + go, /* Name of function */ + n_times /* Argument(s) */ + ); + } + }; + +The macro :func:`PYBIND11_OVERLOAD_PURE` should be used for pure virtual +functions, and :func:`PYBIND11_OVERLOAD` should be used for functions which have +a default implementation. The binding code also needs a few minor adaptations +(highlighted): + +.. code-block:: cpp + :emphasize-lines: 4,6,7 + + PYBIND11_PLUGIN(example) { + py::module m("example", "pybind11 example plugin"); + + py::class_<PyAnimal> animal(m, "Animal"); + animal + .alias<Animal>() + .def(py::init<>()) + .def("go", &Animal::go); + + py::class_<Dog>(m, "Dog", animal) + .def(py::init<>()); + + m.def("call_go", &call_go); + + return m.ptr(); + } + +Importantly, the trampoline helper class is used as the template argument to +:class:`class_`, and a call to :func:`class_::alias` informs the binding +generator that this is merely an alias for the underlying type ``Animal``. +Following this, we are able to define a constructor as usual. + +The Python session below shows how to override ``Animal::go`` and invoke it via +a virtual method call. + +.. code-block:: python + + >>> from example import * + >>> d = Dog() + >>> call_go(d) + u'woof! woof! woof! ' + >>> class Cat(Animal): + ... def go(self, n_times): + ... return "meow! " * n_times + ... + >>> c = Cat() + >>> call_go(c) + u'meow! meow! meow! ' + +.. seealso:: + + The file :file:`example/example12.cpp` contains a complete example that + demonstrates how to override virtual functions using pybind11 in more + detail. + + +Global Interpreter Lock (GIL) +============================= + +The classes :class:`gil_scoped_release` and :class:`gil_scoped_acquire` can be +used to acquire and release the global interpreter lock in the body of a C++ +function call. In this way, long-running C++ code can be parallelized using +multiple Python threads. Taking the previous section as an example, this could +be realized as follows (important changes highlighted): + +.. code-block:: cpp + :emphasize-lines: 8,9,33,34 + + class PyAnimal : public Animal { + public: + /* Inherit the constructors */ + using Animal::Animal; + + /* Trampoline (need one for each virtual function) */ + std::string go(int n_times) { + /* Acquire GIL before calling Python code */ + py::gil_scoped_acquire acquire; + + PYBIND11_OVERLOAD_PURE( + std::string, /* Return type */ + Animal, /* Parent class */ + go, /* Name of function */ + n_times /* Argument(s) */ + ); + } + }; + + PYBIND11_PLUGIN(example) { + py::module m("example", "pybind11 example plugin"); + + py::class_<PyAnimal> animal(m, "Animal"); + animal + .alias<Animal>() + .def(py::init<>()) + .def("go", &Animal::go); + + py::class_<Dog>(m, "Dog", animal) + .def(py::init<>()); + + m.def("call_go", [](Animal *animal) -> std::string { + /* Release GIL before calling into (potentially long-running) C++ code */ + py::gil_scoped_release release; + return call_go(animal); + }); + + return m.ptr(); + } + +Passing STL data structures +=========================== + +When including the additional header file :file:`pybind11/stl.h`, conversions +between ``std::vector<>``, ``std::list<>``, ``std::set<>``, and ``std::map<>`` +and the Python ``list``, ``set`` and ``dict`` data structures are automatically +enabled. The types ``std::pair<>`` and ``std::tuple<>`` are already supported +out of the box with just the core :file:`pybind11/pybind11.h` header. + +.. note:: + + Arbitrary nesting of any of these types is supported. + +.. seealso:: + + The file :file:`example/example2.cpp` contains a complete example that + demonstrates how to pass STL data types in more detail. + +Binding sequence data types, iterators, the slicing protocol, etc. +================================================================== + +Please refer to the supplemental example for details. + +.. seealso:: + + The file :file:`example/example6.cpp` contains a complete example that + shows how to bind a sequence data type, including length queries + (``__len__``), iterators (``__iter__``), the slicing protocol and other + kinds of useful operations. + +Return value policies +===================== + +Python and C++ use wildly different ways of managing the memory and lifetime of +objects managed by them. This can lead to issues when creating bindings for +functions that return a non-trivial type. Just by looking at the type +information, it is not clear whether Python should take charge of the returned +value and eventually free its resources, or if this is handled on the C++ side. +For this reason, pybind11 provides a several `return value policy` annotations +that can be passed to the :func:`module::def` and :func:`class_::def` +functions. The default policy is :enum:`return_value_policy::automatic`. + + ++--------------------------------------------------+---------------------------------------------------------------------------+ +| Return value policy | Description | ++==================================================+===========================================================================+ +| :enum:`return_value_policy::automatic` | Automatic: copy objects returned as values and take ownership of | +| | objects returned as pointers | ++--------------------------------------------------+---------------------------------------------------------------------------+ +| :enum:`return_value_policy::automatic_reference` | Automatic variant 2 : copy objects returned as values and reference | +| | objects returned as pointers | ++--------------------------------------------------+---------------------------------------------------------------------------+ +| :enum:`return_value_policy::copy` | Create a new copy of the returned object, which will be owned by Python | ++--------------------------------------------------+---------------------------------------------------------------------------+ +| :enum:`return_value_policy::take_ownership` | Reference the existing object and take ownership. Python will call | +| | the destructor and delete operator when the reference count reaches zero | ++--------------------------------------------------+---------------------------------------------------------------------------+ +| :enum:`return_value_policy::reference` | Reference the object, but do not take ownership and defer responsibility | +| | for deleting it to C++ (dangerous when C++ code at some point decides to | +| | delete it while Python still has a nonzero reference count) | ++--------------------------------------------------+---------------------------------------------------------------------------+ +| :enum:`return_value_policy::reference_internal` | Reference the object, but do not take ownership. The object is considered | +| | be owned by the C++ instance whose method or property returned it. The | +| | Python object will increase the reference count of this 'parent' by 1 | +| | to ensure that it won't be deallocated while Python is using the 'child' | ++--------------------------------------------------+---------------------------------------------------------------------------+ + +.. warning:: + + Code with invalid call policies might access unitialized memory and free + data structures multiple times, which can lead to hard-to-debug + non-determinism and segmentation faults, hence it is worth spending the + time to understand all the different options above. + +See below for an example that uses the +:enum:`return_value_policy::reference_internal` policy. + +.. code-block:: cpp + + class Example { + public: + Internal &get_internal() { return internal; } + private: + Internal internal; + }; + + PYBIND11_PLUGIN(example) { + py::module m("example", "pybind11 example plugin"); + + py::class_<Example>(m, "Example") + .def(py::init<>()) + .def("get_internal", &Example::get_internal, "Return the internal data", py::return_value_policy::reference_internal); + + return m.ptr(); + } + + +Additional call policies +======================== + +In addition to the above return value policies, further `call policies` can be +specified to indicate dependencies between parameters. There is currently just +one policy named ``keep_alive<Nurse, Patient>``, which indicates that the +argument with index ``Patient`` should be kept alive at least until the +argument with index ``Nurse`` is freed by the garbage collector; argument +indices start at one, while zero refers to the return value. Arbitrarily many +call policies can be specified. + +For instance, binding code for a a list append operation that ties the lifetime +of the newly added element to the underlying container might be declared as +follows: + +.. code-block:: cpp + + py::class_<List>(m, "List") + .def("append", &List::append, py::keep_alive<1, 2>()); + +.. note:: + + ``keep_alive`` is analogous to the ``with_custodian_and_ward`` (if Nurse, + Patient != 0) and ``with_custodian_and_ward_postcall`` (if Nurse/Patient == + 0) policies from Boost.Python. + +.. seealso:: + + The file :file:`example/example13.cpp` contains a complete example that + demonstrates using :class:`keep_alive` in more detail. + +Implicit type conversions +========================= + +Suppose that instances of two types ``A`` and ``B`` are used in a project, and +that an ``A`` can easily be converted into a an instance of type ``B`` (examples of this +could be a fixed and an arbitrary precision number type). + +.. code-block:: cpp + + py::class_<A>(m, "A") + /// ... members ... + + py::class_<B>(m, "B") + .def(py::init<A>()) + /// ... members ... + + m.def("func", + [](const B &) { /* .... */ } + ); + +To invoke the function ``func`` using a variable ``a`` containing an ``A`` +instance, we'd have to write ``func(B(a))`` in Python. On the other hand, C++ +will automatically apply an implicit type conversion, which makes it possible +to directly write ``func(a)``. + +In this situation (i.e. where ``B`` has a constructor that converts from +``A``), the following statement enables similar implicit conversions on the +Python side: + +.. code-block:: cpp + + py::implicitly_convertible<A, B>(); + +Unique pointers +=============== + +Given a class ``Example`` with Python bindings, it's possible to return +instances wrapped in C++11 unique pointers, like so + +.. code-block:: cpp + + std::unique_ptr<Example> create_example() { return std::unique_ptr<Example>(new Example()); } + +.. code-block:: cpp + + m.def("create_example", &create_example); + +In other words, there is nothing special that needs to be done. While returning +unique pointers in this way is allowed, it is *illegal* to use them as function +arguments. For instance, the following function signature cannot be processed +by pybind11. + +.. code-block:: cpp + + void do_something_with_example(std::unique_ptr<Example> ex) { ... } + +The above signature would imply that Python needs to give up ownership of an +object that is passed to this function, which is generally not possible (for +instance, the object might be referenced elsewhere). + +Smart pointers +============== + +This section explains how to pass values that are wrapped in "smart" pointer +types with internal reference counting. For simpler C++11 unique pointers, +please refer to the previous section. + +The binding generator for classes (:class:`class_`) takes an optional second +template type, which denotes a special *holder* type that is used to manage +references to the object. When wrapping a type named ``Type``, the default +value of this template parameter is ``std::unique_ptr<Type>``, which means that +the object is deallocated when Python's reference count goes to zero. + +It is possible to switch to other types of reference counting wrappers or smart +pointers, which is useful in codebases that rely on them. For instance, the +following snippet causes ``std::shared_ptr`` to be used instead. + +.. code-block:: cpp + + py::class_<Example, std::shared_ptr<Example> /* <- holder type */> obj(m, "Example"); + +Note that any particular class can only be associated with a single holder type. + +To enable transparent conversions for functions that take shared pointers as an +argument or that return them, a macro invocation similar to the following must +be declared at the top level before any binding code: + +.. code-block:: cpp + + PYBIND11_DECLARE_HOLDER_TYPE(T, std::shared_ptr<T>); + +.. note:: + + The first argument of :func:`PYBIND11_DECLARE_HOLDER_TYPE` should be a + placeholder name that is used as a template parameter of the second + argument. Thus, feel free to use any identifier, but use it consistently on + both sides; also, don't use the name of a type that already exists in your + codebase. + +One potential stumbling block when using holder types is that they need to be +applied consistently. Can you guess what's broken about the following binding +code? + +.. code-block:: cpp + + class Child { }; + + class Parent { + public: + Parent() : child(std::make_shared<Child>()) { } + Child *get_child() { return child.get(); } /* Hint: ** DON'T DO THIS ** */ + private: + std::shared_ptr<Child> child; + }; + + PYBIND11_PLUGIN(example) { + py::module m("example"); + + py::class_<Child, std::shared_ptr<Child>>(m, "Child"); + + py::class_<Parent, std::shared_ptr<Parent>>(m, "Parent") + .def(py::init<>()) + .def("get_child", &Parent::get_child); + + return m.ptr(); + } + +The following Python code will cause undefined behavior (and likely a +segmentation fault). + +.. code-block:: python + + from example import Parent + print(Parent().get_child()) + +The problem is that ``Parent::get_child()`` returns a pointer to an instance of +``Child``, but the fact that this instance is already managed by +``std::shared_ptr<...>`` is lost when passing raw pointers. In this case, +pybind11 will create a second independent ``std::shared_ptr<...>`` that also +claims ownership of the pointer. In the end, the object will be freed **twice** +since these shared pointers have no way of knowing about each other. + +There are two ways to resolve this issue: + +1. For types that are managed by a smart pointer class, never use raw pointers + in function arguments or return values. In other words: always consistently + wrap pointers into their designated holder types (such as + ``std::shared_ptr<...>``). In this case, the signature of ``get_child()`` + should be modified as follows: + +.. code-block:: cpp + + std::shared_ptr<Child> get_child() { return child; } + +2. Adjust the definition of ``Child`` by specifying + ``std::enable_shared_from_this<T>`` (see cppreference_ for details) as a + base class. This adds a small bit of information to ``Child`` that allows + pybind11 to realize that there is already an existing + ``std::shared_ptr<...>`` and communicate with it. In this case, the + declaration of ``Child`` should look as follows: + +.. _cppreference: http://en.cppreference.com/w/cpp/memory/enable_shared_from_this + +.. code-block:: cpp + + class Child : public std::enable_shared_from_this<Child> { }; + +.. seealso:: + + The file :file:`example/example8.cpp` contains a complete example that + demonstrates how to work with custom reference-counting holder types in + more detail. + +.. _custom_constructors: + +Custom constructors +=================== + +The syntax for binding constructors was previously introduced, but it only +works when a constructor with the given parameters actually exists on the C++ +side. To extend this to more general cases, let's take a look at what actually +happens under the hood: the following statement + +.. code-block:: cpp + + py::class_<Example>(m, "Example") + .def(py::init<int>()); + +is short hand notation for + +.. code-block:: cpp + + py::class_<Example>(m, "Example") + .def("__init__", + [](Example &instance, int arg) { + new (&instance) Example(arg); + } + ); + +In other words, :func:`init` creates an anonymous function that invokes an +in-place constructor. Memory allocation etc. is already take care of beforehand +within pybind11. + +Catching and throwing exceptions +================================ + +When C++ code invoked from Python throws an ``std::exception``, it is +automatically converted into a Python ``Exception``. pybind11 defines multiple +special exception classes that will map to different types of Python +exceptions: + ++--------------------------------------+------------------------------+ +| C++ exception type | Python exception type | ++======================================+==============================+ +| :class:`std::exception` | ``RuntimeError`` | ++--------------------------------------+------------------------------+ +| :class:`std::bad_alloc` | ``MemoryError`` | ++--------------------------------------+------------------------------+ +| :class:`std::domain_error` | ``ValueError`` | ++--------------------------------------+------------------------------+ +| :class:`std::invalid_argument` | ``ValueError`` | ++--------------------------------------+------------------------------+ +| :class:`std::length_error` | ``ValueError`` | ++--------------------------------------+------------------------------+ +| :class:`std::out_of_range` | ``ValueError`` | ++--------------------------------------+------------------------------+ +| :class:`std::range_error` | ``ValueError`` | ++--------------------------------------+------------------------------+ +| :class:`pybind11::stop_iteration` | ``StopIteration`` (used to | +| | implement custom iterators) | ++--------------------------------------+------------------------------+ +| :class:`pybind11::index_error` | ``IndexError`` (used to | +| | indicate out of bounds | +| | accesses in ``__getitem__``, | +| | ``__setitem__``, etc.) | ++--------------------------------------+------------------------------+ +| :class:`pybind11::error_already_set` | Indicates that the Python | +| | exception flag has already | +| | been initialized | ++--------------------------------------+------------------------------+ + +When a Python function invoked from C++ throws an exception, it is converted +into a C++ exception of type :class:`error_already_set` whose string payload +contains a textual summary. + +There is also a special exception :class:`cast_error` that is thrown by +:func:`handle::call` when the input arguments cannot be converted to Python +objects. + +Buffer protocol +=============== + +Python supports an extremely general and convenient approach for exchanging +data between plugin libraries. Types can expose a buffer view [#f1]_, +which provides fast direct access to the raw internal representation. Suppose +we want to bind the following simplistic Matrix class: + +.. code-block:: cpp + + class Matrix { + public: + Matrix(size_t rows, size_t cols) : m_rows(rows), m_cols(cols) { + m_data = new float[rows*cols]; + } + float *data() { return m_data; } + size_t rows() const { return m_rows; } + size_t cols() const { return m_cols; } + private: + size_t m_rows, m_cols; + float *m_data; + }; + +The following binding code exposes the ``Matrix`` contents as a buffer object, +making it possible to cast Matrixes into NumPy arrays. It is even possible to +completely avoid copy operations with Python expressions like +``np.array(matrix_instance, copy = False)``. + +.. code-block:: cpp + + py::class_<Matrix>(m, "Matrix") + .def_buffer([](Matrix &m) -> py::buffer_info { + return py::buffer_info( + m.data(), /* Pointer to buffer */ + sizeof(float), /* Size of one scalar */ + py::format_descriptor<float>::value(), /* Python struct-style format descriptor */ + 2, /* Number of dimensions */ + { m.rows(), m.cols() }, /* Buffer dimensions */ + { sizeof(float) * m.rows(), /* Strides (in bytes) for each index */ + sizeof(float) } + ); + }); + +The snippet above binds a lambda function, which can create ``py::buffer_info`` +description records on demand describing a given matrix. The contents of +``py::buffer_info`` mirror the Python buffer protocol specification. + +.. code-block:: cpp + + struct buffer_info { + void *ptr; + size_t itemsize; + std::string format; + int ndim; + std::vector<size_t> shape; + std::vector<size_t> strides; + }; + +To create a C++ function that can take a Python buffer object as an argument, +simply use the type ``py::buffer`` as one of its arguments. Buffers can exist +in a great variety of configurations, hence some safety checks are usually +necessary in the function body. Below, you can see an basic example on how to +define a custom constructor for the Eigen double precision matrix +(``Eigen::MatrixXd``) type, which supports initialization from compatible +buffer +objects (e.g. a NumPy matrix). + +.. code-block:: cpp + + py::class_<Eigen::MatrixXd>(m, "MatrixXd") + .def("__init__", [](Eigen::MatrixXd &m, py::buffer b) { + /* Request a buffer descriptor from Python */ + py::buffer_info info = b.request(); + + /* Some sanity checks ... */ + if (info.format != py::format_descriptor<double>::value()) + throw std::runtime_error("Incompatible format: expected a double array!"); + + if (info.ndim != 2) + throw std::runtime_error("Incompatible buffer dimension!"); + + if (info.strides[0] == sizeof(double)) { + /* Buffer has the right layout -- directly copy. */ + new (&m) Eigen::MatrixXd(info.shape[0], info.shape[1]); + memcpy(m.data(), info.ptr, sizeof(double) * m.size()); + } else { + /* Oops -- the buffer is transposed */ + new (&m) Eigen::MatrixXd(info.shape[1], info.shape[0]); + memcpy(m.data(), info.ptr, sizeof(double) * m.size()); + m.transposeInPlace(); + } + }); + +.. seealso:: + + The file :file:`example/example7.cpp` contains a complete example that + demonstrates using the buffer protocol with pybind11 in more detail. + +.. [#f1] http://docs.python.org/3/c-api/buffer.html + +NumPy support +============= + +By exchanging ``py::buffer`` with ``py::array`` in the above snippet, we can +restrict the function so that it only accepts NumPy arrays (rather than any +type of Python object satisfying the buffer protocol). + +In many situations, we want to define a function which only accepts a NumPy +array of a certain data type. This is possible via the ``py::array_t<T>`` +template. For instance, the following function requires the argument to be a +dense array of doubles in C-style ordering. + +.. code-block:: cpp + + void f(py::array_t<double> array); + +When it is invoked with a different type (e.g. an integer), the binding code +will attempt to cast the input into a NumPy array of the requested type. Note +that this feature requires the :file:``pybind11/numpy.h`` header to be +included. + +Vectorizing functions +===================== + +Suppose we want to bind a function with the following signature to Python so +that it can process arbitrary NumPy array arguments (vectors, matrices, general +N-D arrays) in addition to its normal arguments: + +.. code-block:: cpp + + double my_func(int x, float y, double z); + +After including the ``pybind11/numpy.h`` header, this is extremely simple: + +.. code-block:: cpp + + m.def("vectorized_func", py::vectorize(my_func)); + +Invoking the function like below causes 4 calls to be made to ``my_func`` with +each of the the array elements. The significant advantage of this compared to +solutions like ``numpy.vectorize()`` is that the loop over the elements runs +entirely on the C++ side and can be crunched down into a tight, optimized loop +by the compiler. The result is returned as a NumPy array of type +``numpy.dtype.float64``. + +.. code-block:: python + + >>> x = np.array([[1, 3],[5, 7]]) + >>> y = np.array([[2, 4],[6, 8]]) + >>> z = 3 + >>> result = vectorized_func(x, y, z) + +The scalar argument ``z`` is transparently replicated 4 times. The input +arrays ``x`` and ``y`` are automatically converted into the right types (they +are of type ``numpy.dtype.int64`` but need to be ``numpy.dtype.int32`` and +``numpy.dtype.float32``, respectively) + +Sometimes we might want to explitly exclude an argument from the vectorization +because it makes little sense to wrap it in a NumPy array. For instance, +suppose the function signature was + +.. code-block:: cpp + + double my_func(int x, float y, my_custom_type *z); + +This can be done with a stateful Lambda closure: + +.. code-block:: cpp + + // Vectorize a lambda function with a capture object (e.g. to exclude some arguments from the vectorization) + m.def("vectorized_func", + [](py::array_t<int> x, py::array_t<float> y, my_custom_type *z) { + auto stateful_closure = [z](int x, float y) { return my_func(x, y, z); }; + return py::vectorize(stateful_closure)(x, y); + } + ); + +In cases where the computation is too complicated to be reduced to +``vectorize``, it will be necessary to create and access the buffer contents +manually. The following snippet contains a complete example that shows how this +works (the code is somewhat contrived, since it could have been done more +simply using ``vectorize``). + +.. code-block:: cpp + + #include <pybind11/pybind11.h> + #include <pybind11/numpy.h> + + namespace py = pybind11; + + py::array_t<double> add_arrays(py::array_t<double> input1, py::array_t<double> input2) { + auto buf1 = input1.request(), buf2 = input2.request(); + + if (buf1.ndim != 1 || buf2.ndim != 1) + throw std::runtime_error("Number of dimensions must be one"); + + if (buf1.shape[0] != buf2.shape[0]) + throw std::runtime_error("Input shapes must match"); + + auto result = py::array(py::buffer_info( + nullptr, /* Pointer to data (nullptr -> ask NumPy to allocate!) */ + sizeof(double), /* Size of one item */ + py::format_descriptor<double>::value(), /* Buffer format */ + buf1.ndim, /* How many dimensions? */ + { buf1.shape[0] }, /* Number of elements for each dimension */ + { sizeof(double) } /* Strides for each dimension */ + )); + + auto buf3 = result.request(); + + double *ptr1 = (double *) buf1.ptr, + *ptr2 = (double *) buf2.ptr, + *ptr3 = (double *) buf3.ptr; + + for (size_t idx = 0; idx < buf1.shape[0]; idx++) + ptr3[idx] = ptr1[idx] + ptr2[idx]; + + return result; + } + + PYBIND11_PLUGIN(test) { + py::module m("test"); + m.def("add_arrays", &add_arrays, "Add two NumPy arrays"); + return m.ptr(); + } + +.. seealso:: + + The file :file:`example/example10.cpp` contains a complete example that + demonstrates using :func:`vectorize` in more detail. + +Functions taking Python objects as arguments +============================================ + +pybind11 exposes all major Python types using thin C++ wrapper classes. These +wrapper classes can also be used as parameters of functions in bindings, which +makes it possible to directly work with native Python types on the C++ side. +For instance, the following statement iterates over a Python ``dict``: + +.. code-block:: cpp + + void print_dict(py::dict dict) { + /* Easily interact with Python types */ + for (auto item : dict) + std::cout << "key=" << item.first << ", " + << "value=" << item.second << std::endl; + } + +Available types include :class:`handle`, :class:`object`, :class:`bool_`, +:class:`int_`, :class:`float_`, :class:`str`, :class:`bytes`, :class:`tuple`, +:class:`list`, :class:`dict`, :class:`slice`, :class:`capsule`, +:class:`function`, :class:`buffer`, :class:`array`, and :class:`array_t`. + +In this kind of mixed code, it is often necessary to convert arbitrary C++ +types to Python, which can be done using :func:`cast`: + +.. code-block:: cpp + + MyClass *cls = ..; + py::object obj = py::cast(cls); + +The reverse direction uses the following syntax: + +.. code-block:: cpp + + py::object obj = ...; + MyClass *cls = obj.cast<MyClass *>(); + +When conversion fails, both directions throw the exception :class:`cast_error`. + +.. seealso:: + + The file :file:`example/example2.cpp` contains a complete example that + demonstrates passing native Python types in more detail. + +Default arguments revisited +=========================== + +The section on :ref:`default_args` previously discussed basic usage of default +arguments using pybind11. One noteworthy aspect of their implementation is that +default arguments are converted to Python objects right at declaration time. +Consider the following example: + +.. code-block:: cpp + + py::class_<MyClass>("MyClass") + .def("myFunction", py::arg("arg") = SomeType(123)); + +In this case, pybind11 must already be set up to deal with values of the type +``SomeType`` (via a prior instantiation of ``py::class_<SomeType>``), or an +exception will be thrown. + +Another aspect worth highlighting is that the "preview" of the default argument +in the function signature is generated using the object's ``__repr__`` method. +If not available, the signature may not be very helpful, e.g.: + +.. code-block:: python + + FUNCTIONS + ... + | myFunction(...) + | Signature : (MyClass, arg : SomeType = <SomeType object at 0x101b7b080>) -> NoneType + ... + +The first way of addressing this is by defining ``SomeType.__repr__``. +Alternatively, it is possible to specify the human-readable preview of the +default argument manually using the ``arg_t`` notation: + +.. code-block:: cpp + + py::class_<MyClass>("MyClass") + .def("myFunction", py::arg_t<SomeType>("arg", SomeType(123), "SomeType(123)")); + +Sometimes it may be necessary to pass a null pointer value as a default +argument. In this case, remember to cast it to the underlying type in question, +like so: + +.. code-block:: cpp + + py::class_<MyClass>("MyClass") + .def("myFunction", py::arg("arg") = (SomeType *) nullptr); + +Partitioning code over multiple extension modules +================================================= + +It's straightforward to split binding code over multiple extension modules, +while referencing types that are declared elsewhere. Everything "just" works +without any special precautions. One exception to this rule occurs when +extending a type declared in another extension module. Recall the basic example +from Section :ref:`inheritance`. + +.. code-block:: cpp + + py::class_<Pet> pet(m, "Pet"); + pet.def(py::init<const std::string &>()) + .def_readwrite("name", &Pet::name); + + py::class_<Dog>(m, "Dog", pet /* <- specify parent */) + .def(py::init<const std::string &>()) + .def("bark", &Dog::bark); + +Suppose now that ``Pet`` bindings are defined in a module named ``basic``, +whereas the ``Dog`` bindings are defined somewhere else. The challenge is of +course that the variable ``pet`` is not available anymore though it is needed +to indicate the inheritance relationship to the constructor of ``class_<Dog>``. +However, it can be acquired as follows: + +.. code-block:: cpp + + py::object pet = (py::object) py::module::import("basic").attr("Pet"); + + py::class_<Dog>(m, "Dog", pet) + .def(py::init<const std::string &>()) + .def("bark", &Dog::bark); + +Alternatively, we can rely on the ``base`` tag, which performs an automated +lookup of the corresponding Python type. However, this also requires invoking +the ``import`` function once to ensure that the pybind11 binding code of the +module ``basic`` has been executed. + +.. code-block:: cpp + + py::module::import("basic"); + + py::class_<Dog>(m, "Dog", py::base<Pet>()) + .def(py::init<const std::string &>()) + .def("bark", &Dog::bark); + +Naturally, both methods will fail when there are cyclic dependencies. + +Note that compiling code which has its default symbol visibility set to +*hidden* (e.g. via the command line flag ``-fvisibility=hidden`` on GCC/Clang) can interfere with the +ability to access types defined in another extension module. Workarounds +include changing the global symbol visibility (not recommended, because it will +lead unnecessarily large binaries) or manually exporting types that are +accessed by multiple extension modules: + +.. code-block:: cpp + + #ifdef _WIN32 + # define EXPORT_TYPE __declspec(dllexport) + #else + # define EXPORT_TYPE __attribute__ ((visibility("default"))) + #endif + + class EXPORT_TYPE Dog : public Animal { + ... + }; + + +Treating STL data structures as opaque objects +============================================== + +pybind11 heavily relies on a template matching mechanism to convert parameters +and return values that are constructed from STL data types such as vectors, +linked lists, hash tables, etc. This even works in a recursive manner, for +instance to deal with lists of hash maps of pairs of elementary and custom +types, etc. + +A fundamental limitation of this approach is that the internal conversion +between Python and C++ types involves a copy operation that prevents +pass-by-reference semantics. What does this mean? + +Suppose we bind the following function + +.. code-block:: cpp + + void append_1(std::vector<int> &v) { + v.push_back(1); + } + +and call it as follows from Python: + +.. code-block:: python + + >>> v = [5, 6] + >>> append_1(v) + >>> print(v) + [5, 6] + +As you can see, when passing STL data structures by reference, modifications +are not propagated back the Python side. To deal with situations where this +desirable, pybind11 contains a simple template wrapper class named ``opaque<T>``. + +``opaque<T>`` disables the underlying template machinery for +``T`` and can be used to treat STL types as opaque objects, whose contents are +never inspected or extracted (thus, they can be passed by reference). +The downside of this approach is that it the binding code becomes a bit more +wordy. The above function can be bound using the following wrapper code: + +.. code-block:: cpp + + m.def("append_1", [](py::opaque<std::vector<int>> &v) { append_1(v); }); + +Opaque types must also have a dedicated ``class_`` declaration to define a +set of admissible operations. + +.. seealso:: + + The file :file:`example/example14.cpp` contains a complete example that + demonstrates how to create opaque types using pybind11 in more detail. + +Pickling support +================ + +Python's ``pickle`` module provides a powerful facility to serialize and +de-serialize a Python object graph into a binary data stream. To pickle and +unpickle C++ classes using pybind11, two additional functions must be provided. +Suppose the class in question has the following signature: + +.. code-block:: cpp + + class Pickleable { + public: + Pickleable(const std::string &value) : m_value(value) { } + const std::string &value() const { return m_value; } + + void setExtra(int extra) { m_extra = extra; } + int extra() const { return m_extra; } + private: + std::string m_value; + int m_extra = 0; + }; + +The binding code including the requisite ``__setstate__`` and ``__getstate__`` methods [#f2]_ +looks as follows: + +.. code-block:: cpp + + py::class_<Pickleable>(m, "Pickleable") + .def(py::init<std::string>()) + .def("value", &Pickleable::value) + .def("extra", &Pickleable::extra) + .def("setExtra", &Pickleable::setExtra) + .def("__getstate__", [](const Pickleable &p) { + /* Return a tuple that fully encodes the state of the object */ + return py::make_tuple(p.value(), p.extra()); + }) + .def("__setstate__", [](Pickleable &p, py::tuple t) { + if (t.size() != 2) + throw std::runtime_error("Invalid state!"); + + /* Invoke the in-place constructor. Note that this is needed even + when the object just has a trivial default constructor */ + new (&p) Pickleable(t[0].cast<std::string>()); + + /* Assign any additional state */ + p.setExtra(t[1].cast<int>()); + }); + +An instance can now be pickled as follows: + +.. code-block:: python + + try: + import cPickle as pickle # Use cPickle on Python 2.7 + except ImportError: + import pickle + + p = Pickleable("test_value") + p.setExtra(15) + data = pickle.dumps(p, -1) + +Note that only the cPickle module is supported on Python 2.7. It is also +important to request usage of the highest protocol version using the ``-1`` +argument to ``dumps``. Failure to follow these two steps will lead to important +pybind11 memory allocation routines to be skipped during unpickling, which will +likely cause memory corruption and/or segmentation faults. + +.. seealso:: + + The file :file:`example/example15.cpp` contains a complete example that + demonstrates how to pickle and unpickle types using pybind11 in more detail. + +.. [#f2] http://docs.python.org/3/library/pickle.html#pickling-class-instances + +Generating documentation using Sphinx +===================================== + +Sphinx [#f3]_ has the ability to inspect the signatures and documentation +strings in pybind11-based extension modules to automatically generate beautiful +documentation in a variety formats. The pbtest repository [#f4]_ contains a +simple example repository which uses this approach. + +There are two potential gotchas when using this approach: first, make sure that +the resulting strings do not contain any :kbd:`TAB` characters, which break the +docstring parsing routines. You may want to use C++11 raw string literals, +which are convenient for multi-line comments. Conveniently, any excess +indentation will be automatically be removed by Sphinx. However, for this to +work, it is important that all lines are indented consistently, i.e.: + +.. code-block:: cpp + + // ok + m.def("foo", &foo, R"mydelimiter( + The foo function + + Parameters + ---------- + )mydelimiter"); + + // *not ok* + m.def("foo", &foo, R"mydelimiter(The foo function + + Parameters + ---------- + )mydelimiter"); + +.. [#f3] http://www.sphinx-doc.org +.. [#f4] http://github.com/pybind/pbtest + diff --git a/stormpy/resources/pybind11/docs/basics.rst b/stormpy/resources/pybind11/docs/basics.rst new file mode 100644 index 000000000..42ff6e42e --- /dev/null +++ b/stormpy/resources/pybind11/docs/basics.rst @@ -0,0 +1,280 @@ +.. _basics: + +First steps +########### + +This sections demonstrates the basic features of pybind11. Before getting +started, make sure that development environment is set up to compile the +included set of examples, which also double as test cases. + + +Compiling the test cases +======================== + +Linux/MacOS +----------- + +On Linux you'll need to install the **python-dev** or **python3-dev** packages as +well as **cmake**. On Mac OS, the included python version works out of the box, +but **cmake** must still be installed. + +After installing the prerequisites, run + +.. code-block:: bash + + cmake . + make -j 4 + +followed by + +.. code-block:: bash + + make test + +Windows +------- + +On Windows, use the `CMake GUI`_ to create a Visual Studio project. Note that +only the 2015 release and newer versions are supported since pybind11 relies on +various C++11 language features that break older versions of Visual Studio. +After running CMake, open the created :file:`pybind11.sln` file and perform a +release build, which will will produce a file named +:file:`Release\\example.pyd`. Copy this file to the :file:`example` directory +and run :file:`example\\run_test.py` using the targeted Python version. + +.. _`CMake GUI`: https://cmake.org/runningcmake + +.. Note:: + + When all tests fail, make sure that + + 1. The Python binary and the testcases are compiled for the same processor + type and bitness (i.e. either **i386** or **x86_64**) + + 2. The Python binary used to run :file:`example\\run_test.py` matches the + Python version specified in the CMake GUI. This is controlled via + the ``PYTHON_EXECUTABLE`` ``PYTHON_INCLUDE_DIR``, and + ``PYTHON_LIBRARY`` variables. + +.. seealso:: + + Advanced users who are already familiar with Boost.Python may want to skip + the tutorial and look at the test cases in the :file:`example` directory, + which exercise all features of pybind11. + +Creating bindings for a simple function +======================================= + +Let's start by creating Python bindings for an extremely simple function, which +adds two numbers and returns their result: + +.. code-block:: cpp + + int add(int i, int j) { + return i + j; + } + +For simplicity [#f1]_, we'll put both this function and the binding code into +a file named :file:`example.cpp` with the following contents: + +.. code-block:: cpp + + #include <pybind11/pybind11.h> + + int add(int i, int j) { + return i + j; + } + + namespace py = pybind11; + + PYBIND11_PLUGIN(example) { + py::module m("example", "pybind11 example plugin"); + + m.def("add", &add, "A function which adds two numbers"); + + return m.ptr(); + } + +The :func:`PYBIND11_PLUGIN` macro creates a function that will be called when an +``import`` statement is issued from within Python. The next line creates a +module named ``example`` (with the supplied docstring). The method +:func:`module::def` generates binding code that exposes the +``add()`` function to Python. The last line returns the internal Python object +associated with ``m`` to the Python interpreter. + +.. note:: + + Notice how little code was needed to expose our function to Python: all + details regarding the function's parameters and return value were + automatically inferred using template metaprogramming. This overall + approach and the used syntax are borrowed from Boost.Python, though the + underlying implementation is very different. + +pybind11 is a header-only-library, hence it is not necessary to link against +any special libraries (other than Python itself). On Windows, use the CMake +build file discussed in section :ref:`cmake`. On Linux and Mac OS, the above +example can be compiled using the following command + +.. code-block:: bash + + $ c++ -O3 -shared -std=c++11 -I <path-to-pybind11>/include `python-config --cflags --ldflags --libs` example.cpp -o example.so + +In general, it is advisable to include several additional build parameters +that can considerably reduce the size of the created binary. Refer to section +:ref:`cmake` for a detailed example of a suitable cross-platform CMake-based +build system. + +Assuming that the created file :file:`example.so` (:file:`example.pyd` on Windows) +is located in the current directory, the following interactive Python session +shows how to load and execute the example. + +.. code-block:: python + + $ python + Python 2.7.10 (default, Aug 22 2015, 20:33:39) + [GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.1)] on darwin + Type "help", "copyright", "credits" or "license" for more information. + >>> import example + >>> example.add(1, 2) + 3L + >>> + +.. _keyword_args: + +Keyword arguments +================= + +With a simple modification code, it is possible to inform Python about the +names of the arguments ("i" and "j" in this case). + +.. code-block:: cpp + + m.def("add", &add, "A function which adds two numbers", + py::arg("i"), py::arg("j")); + +:class:`arg` is one of several special tag classes which can be used to pass +metadata into :func:`module::def`. With this modified binding code, we can now +call the function using keyword arguments, which is a more readable alternative +particularly for functions taking many parameters: + +.. code-block:: python + + >>> import example + >>> example.add(i=1, j=2) + 3L + +The keyword names also appear in the function signatures within the documentation. + +.. code-block:: python + + >>> help(example) + + .... + + FUNCTIONS + add(...) + Signature : (i: int, j: int) -> int + + A function which adds two numbers + +.. _default_args: + +Default arguments +================= + +Suppose now that the function to be bound has default arguments, e.g.: + +.. code-block:: cpp + + int add(int i = 1, int j = 2) { + return i + j; + } + +Unfortunately, pybind11 cannot automatically extract these parameters, since they +are not part of the function's type information. However, they are simple to specify +using an extension of :class:`arg`: + +.. code-block:: cpp + + m.def("add", &add, "A function which adds two numbers", + py::arg("i") = 1, py::arg("j") = 2); + +The default values also appear within the documentation. + +.. code-block:: python + + >>> help(example) + + .... + + FUNCTIONS + add(...) + Signature : (i: int = 1, j: int = 2) -> int + + A function which adds two numbers + +.. _supported_types: + +Supported data types +==================== + +The following basic data types are supported out of the box (some may require +an additional extension header to be included). To pass other data structures +as arguments and return values, refer to the section on binding :ref:`classes`. + ++----------------------------+--------------------------+-----------------------+ +| Data type | Description | Header file | ++============================+==========================+=======================+ +| int8_t, uint8_t | 8-bit integers | pybind11/pybind11.h | ++----------------------------+--------------------------+-----------------------+ +| int16_t, uint16_t | 16-bit integers | pybind11/pybind11.h | ++----------------------------+--------------------------+-----------------------+ +| int32_t, uint32_t | 32-bit integers | pybind11/pybind11.h | ++----------------------------+--------------------------+-----------------------+ +| int64_t, uint64_t | 64-bit integers | pybind11/pybind11.h | ++----------------------------+--------------------------+-----------------------+ +| ssize_t, size_t | Platform-dependent size | pybind11/pybind11.h | ++----------------------------+--------------------------+-----------------------+ +| float, double | Floating point types | pybind11/pybind11.h | ++----------------------------+--------------------------+-----------------------+ +| bool | Two-state Boolean type | pybind11/pybind11.h | ++----------------------------+--------------------------+-----------------------+ +| char | Character literal | pybind11/pybind11.h | ++----------------------------+--------------------------+-----------------------+ +| wchar_t | Wide character literal | pybind11/pybind11.h | ++----------------------------+--------------------------+-----------------------+ +| const char * | UTF-8 string literal | pybind11/pybind11.h | ++----------------------------+--------------------------+-----------------------+ +| const wchar_t * | Wide string literal | pybind11/pybind11.h | ++----------------------------+--------------------------+-----------------------+ +| std::string | STL dynamic UTF-8 string | pybind11/pybind11.h | ++----------------------------+--------------------------+-----------------------+ +| std::wstring | STL dynamic wide string | pybind11/pybind11.h | ++----------------------------+--------------------------+-----------------------+ +| std::pair<T1, T2> | Pair of two custom types | pybind11/pybind11.h | ++----------------------------+--------------------------+-----------------------+ +| std::tuple<....> | Arbitrary tuple of types | pybind11/pybind11.h | ++----------------------------+--------------------------+-----------------------+ +| std::complex<T> | Complex numbers | pybind11/complex.h | ++----------------------------+--------------------------+-----------------------+ +| std::array<T, Size> | STL static array | pybind11/stl.h | ++----------------------------+--------------------------+-----------------------+ +| std::vector<T> | STL dynamic array | pybind11/stl.h | ++----------------------------+--------------------------+-----------------------+ +| std::list<T> | STL linked list | pybind11/stl.h | ++----------------------------+--------------------------+-----------------------+ +| std::map<T1, T2> | STL ordered map | pybind11/stl.h | ++----------------------------+--------------------------+-----------------------+ +| std::unordered_map<T1, T2> | STL unordered map | pybind11/stl.h | ++----------------------------+--------------------------+-----------------------+ +| std::set<T> | STL ordered set | pybind11/stl.h | ++----------------------------+--------------------------+-----------------------+ +| std::unordered_set<T> | STL unordered set | pybind11/stl.h | ++----------------------------+--------------------------+-----------------------+ +| std::function<...> | STL polymorphic function | pybind11/functional.h | ++----------------------------+--------------------------+-----------------------+ + + +.. [#f1] In practice, implementation and binding code will generally be located + in separate files. + diff --git a/stormpy/resources/pybind11/docs/benchmark.py b/stormpy/resources/pybind11/docs/benchmark.py new file mode 100644 index 000000000..6f02e92ff --- /dev/null +++ b/stormpy/resources/pybind11/docs/benchmark.py @@ -0,0 +1,90 @@ +import random +import os +import time +import datetime as dt + +nfns = 4 # Functions per class +nargs = 4 # Arguments per function + + +def generate_dummy_code_pybind11(nclasses=10): + decl = "" + bindings = "" + + for cl in range(nclasses): + decl += "class cl%03i;\n" % cl + decl += '\n' + + for cl in range(nclasses): + decl += "class cl%03i {\n" % cl + decl += "public:\n" + bindings += ' py::class_<cl%03i>(m, "cl%03i")\n' % (cl, cl) + for fn in range(nfns): + ret = random.randint(0, nclasses - 1) + params = [random.randint(0, nclasses - 1) for i in range(nargs)] + decl += " cl%03i *fn_%03i(" % (ret, fn) + decl += ", ".join("cl%03i *" % p for p in params) + decl += ");\n" + bindings += ' .def("fn_%03i", &cl%03i::fn_%03i)\n' % \ + (fn, cl, fn) + decl += "};\n\n" + bindings += ' ;\n' + + result = "#include <pybind11/pybind11.h>\n\n" + result += "namespace py = pybind11;\n\n" + result += decl + '\n' + result += "PYBIND11_PLUGIN(example) {\n" + result += " py::module m(\"example\");" + result += bindings + result += " return m.ptr();" + result += "}" + return result + + +def generate_dummy_code_boost(nclasses=10): + decl = "" + bindings = "" + + for cl in range(nclasses): + decl += "class cl%03i;\n" % cl + decl += '\n' + + for cl in range(nclasses): + decl += "class cl%03i {\n" % cl + decl += "public:\n" + bindings += ' py::class_<cl%03i>("cl%03i")\n' % (cl, cl) + for fn in range(nfns): + ret = random.randint(0, nclasses - 1) + params = [random.randint(0, nclasses - 1) for i in range(nargs)] + decl += " cl%03i *fn_%03i(" % (ret, fn) + decl += ", ".join("cl%03i *" % p for p in params) + decl += ");\n" + bindings += ' .def("fn_%03i", &cl%03i::fn_%03i, py::return_value_policy<py::manage_new_object>())\n' % \ + (fn, cl, fn) + decl += "};\n\n" + bindings += ' ;\n' + + result = "#include <boost/python.hpp>\n\n" + result += "namespace py = boost::python;\n\n" + result += decl + '\n' + result += "BOOST_PYTHON_MODULE(example) {\n" + result += bindings + result += "}" + return result + + +for codegen in [generate_dummy_code_pybind11, generate_dummy_code_boost]: + print ("{") + for i in range(0, 10): + nclasses = 2 ** i + with open("test.cpp", "w") as f: + f.write(codegen(nclasses)) + n1 = dt.datetime.now() + os.system("g++ -Os -shared -rdynamic -undefined dynamic_lookup " + "-fvisibility=hidden -std=c++14 test.cpp -I include " + "-I /System/Library/Frameworks/Python.framework/Headers -o test.so") + n2 = dt.datetime.now() + elapsed = (n2 - n1).total_seconds() + size = os.stat('test.so').st_size + print(" {%i, %f, %i}," % (nclasses * nfns, elapsed, size)) + print ("}") diff --git a/stormpy/resources/pybind11/docs/benchmark.rst b/stormpy/resources/pybind11/docs/benchmark.rst new file mode 100644 index 000000000..c31e2902d --- /dev/null +++ b/stormpy/resources/pybind11/docs/benchmark.rst @@ -0,0 +1,83 @@ +Benchmark +========= + +The following is the result of a synthetic benchmark comparing both compilation +time and module size of pybind11 against Boost.Python. + +Setup +----- + +A python script (see the ``docs/benchmark.py`` file) was used to generate a set +of files with dummy classes whose count increases for each successive benchmark +(between 1 and 2048 classes in powers of two). Each class has four methods with +a randomly generated signature with a return value and four arguments. (There +was no particular reason for this setup other than the desire to generate many +unique function signatures whose count could be controlled in a simple way.) + +Here is an example of the binding code for one class: + +.. code-block:: cpp + + ... + class cl034 { + public: + cl279 *fn_000(cl084 *, cl057 *, cl065 *, cl042 *); + cl025 *fn_001(cl098 *, cl262 *, cl414 *, cl121 *); + cl085 *fn_002(cl445 *, cl297 *, cl145 *, cl421 *); + cl470 *fn_003(cl200 *, cl323 *, cl332 *, cl492 *); + }; + ... + + PYBIND11_PLUGIN(example) { + py::module m("example"); + ... + py::class_<cl034>(m, "cl034") + .def("fn_000", &cl034::fn_000) + .def("fn_001", &cl034::fn_001) + .def("fn_002", &cl034::fn_002) + .def("fn_003", &cl034::fn_003) + ... + return m.ptr(); + } + +The Boost.Python version looks almost identical except that a return value +policy had to be specified as an argument to ``def()``. For both libraries, +compilation was done with + +.. code-block:: bash + + Apple LLVM version 7.0.2 (clang-700.1.81) + +and the following compilation flags + +.. code-block:: bash + + g++ -Os -shared -rdynamic -undefined dynamic_lookup -fvisibility=hidden -std=c++14 + +Compilation time +---------------- + +The following log-log plot shows how the compilation time grows for an +increasing number of class and function declarations. pybind11 includes many +fewer headers, which initially leads to shorter compilation times, but the +performance is ultimately fairly similar (pybind11 is 19.8 seconds faster for +the largest largest file with 2048 classes and a total of 8192 methods -- a +modest **1.2x** speedup relative to Boost.Python, which required 116.35 +seconds). + +.. image:: pybind11_vs_boost_python1.svg + +Module size +----------- + +Differences between the two libraries become much more pronounced when +considering the file size of the generated Python plugin: for the largest file, +the binary generated by Boost.Python required 16.8 MiB, which was **2.17 +times** / **9.1 megabytes** larger than the output generated by pybind11. For +very small inputs, Boost.Python has an edge in the plot below -- however, note +that it stores many definitions in an external library, whose size was not +included here, hence the comparison is slightly shifted in Boost.Python's +favor. + +.. image:: pybind11_vs_boost_python2.svg + diff --git a/stormpy/resources/pybind11/docs/changelog.rst b/stormpy/resources/pybind11/docs/changelog.rst new file mode 100644 index 000000000..92b23670b --- /dev/null +++ b/stormpy/resources/pybind11/docs/changelog.rst @@ -0,0 +1,93 @@ +.. _changelog: + +Changelog +######### + +1.5 (not yet released) +---------------------- +* For polymorphic types, use RTTI to try to return the closest type registered with pybind11. +* Pickling support for serializing and unserializing C++ instances to a byte stream in Python +* Added a convenience routine ``make_iterator()`` which turns a range indicated + by a pair of C++ iterators into a iterable Python object +* Added ``len()`` and a variadic ``make_tuple()`` function +* Addressed a rare issue that could confuse the current virtual function + dispatcher and another that could lead to crashes in multi-threaded + applications +* Added a ``get_include()`` function to the Python module that returns the path + of the directory containing the installed pybind11 header files +* Documentation improvements: import issues, symbol visibility, pickling, limitations + +1.4 (April 7, 2016) +-------------------------- +* Transparent type conversion for ``std::wstring`` and ``wchar_t`` +* Allow passing ``nullptr``-valued strings +* Transparent passing of ``void *`` pointers using capsules +* Transparent support for returning values wrapped in ``std::unique_ptr<>`` +* Improved docstring generation for compatibility with Sphinx +* Nicer debug error message when default parameter construction fails +* Support for "opaque" types that bypass the transparent conversion layer for STL containers +* Redesigned type casting interface to avoid ambiguities that could occasionally cause compiler errors +* Redesigned property implementation; fixes crashes due to an unfortunate default return value policy +* Anaconda package generation support + +1.3 (March 8, 2016) +-------------------------- + +* Added support for the Intel C++ compiler (v15+) +* Added support for the STL unordered set/map data structures +* Added support for the STL linked list data structure +* NumPy-style broadcasting support in ``pybind11::vectorize`` +* pybind11 now displays more verbose error messages when ``arg::operator=()`` fails +* pybind11 internal data structures now live in a version-dependent namespace to avoid ABI issues +* Many, many bugfixes involving corner cases and advanced usage + +1.2 (February 7, 2016) +-------------------------- + +* Optional: efficient generation of function signatures at compile time using C++14 +* Switched to a simpler and more general way of dealing with function default + arguments. Unused keyword arguments in function calls are now detected and + cause errors as expected +* New ``keep_alive`` call policy analogous to Boost.Python's ``with_custodian_and_ward`` +* New ``pybind11::base<>`` attribute to indicate a subclass relationship +* Improved interface for RAII type wrappers in ``pytypes.h`` +* Use RAII type wrappers consistently within pybind11 itself. This + fixes various potential refcount leaks when exceptions occur +* Added new ``bytes`` RAII type wrapper (maps to ``string`` in Python 2.7) +* Made handle and related RAII classes const correct, using them more + consistently everywhere now +* Got rid of the ugly ``__pybind11__`` attributes on the Python side---they are + now stored in a C++ hash table that is not visible in Python +* Fixed refcount leaks involving NumPy arrays and bound functions +* Vastly improved handling of shared/smart pointers +* Removed an unnecessary copy operation in ``pybind11::vectorize`` +* Fixed naming clashes when both pybind11 and NumPy headers are included +* Added conversions for additional exception types +* Documentation improvements (using multiple extension modules, smart pointers, + other minor clarifications) +* unified infrastructure for parsing variadic arguments in ``class_`` and cpp_function +* Fixed license text (was: ZLIB, should have been: 3-clause BSD) +* Python 3.2 compatibility +* Fixed remaining issues when accessing types in another plugin module +* Added enum comparison and casting methods +* Improved SFINAE-based detection of whether types are copy-constructible +* Eliminated many warnings about unused variables and the use of ``offsetof()`` +* Support for ``std::array<>`` conversions + +1.1 (December 7, 2015) +-------------------------- + +* Documentation improvements (GIL, wrapping functions, casting, fixed many typos) +* Generalized conversion of integer types +* Improved support for casting function objects +* Improved support for ``std::shared_ptr<>`` conversions +* Initial support for ``std::set<>`` conversions +* Fixed type resolution issue for types defined in a separate plugin module +* Cmake build system improvements +* Factored out generic functionality to non-templated code (smaller code size) +* Added a code size / compile time benchmark vs Boost.Python +* Added an appveyor CI script + +1.0 (October 15, 2015) +------------------------ +* Initial release diff --git a/stormpy/resources/pybind11/docs/classes.rst b/stormpy/resources/pybind11/docs/classes.rst new file mode 100644 index 000000000..c98f8da2e --- /dev/null +++ b/stormpy/resources/pybind11/docs/classes.rst @@ -0,0 +1,331 @@ +.. _classes: + +Object-oriented code +#################### + +Creating bindings for a custom type +=================================== + +Let's now look at a more complex example where we'll create bindings for a +custom C++ data structure named ``Pet``. Its definition is given below: + +.. code-block:: cpp + + struct Pet { + Pet(const std::string &name) : name(name) { } + void setName(const std::string &name_) { name = name_; } + const std::string &getName() const { return name; } + + std::string name; + }; + +The binding code for ``Pet`` looks as follows: + +.. code-block:: cpp + + #include <pybind11/pybind11.h> + + namespace py = pybind11; + + PYBIND11_PLUGIN(example) { + py::module m("example", "pybind11 example plugin"); + + py::class_<Pet>(m, "Pet") + .def(py::init<const std::string &>()) + .def("setName", &Pet::setName) + .def("getName", &Pet::getName); + + return m.ptr(); + } + +:class:`class_` creates bindings for a C++ `class` or `struct`-style data +structure. :func:`init` is a convenience function that takes the types of a +constructor's parameters as template arguments and wraps the corresponding +constructor (see the :ref:`custom_constructors` section for details). An +interactive Python session demonstrating this example is shown below: + +.. code-block:: python + + % python + >>> import example + >>> p = example.Pet('Molly') + >>> print(p) + <example.Pet object at 0x10cd98060> + >>> p.getName() + u'Molly' + >>> p.setName('Charly') + >>> p.getName() + u'Charly' + +.. seealso:: + + Static member functions can be bound in the same way using + :func:`class_::def_static`. + +Keyword and default arguments +============================= +It is possible to specify keyword and default arguments using the syntax +discussed in the previous chapter. Refer to the sections :ref:`keyword_args` +and :ref:`default_args` for details. + +Binding lambda functions +======================== + +Note how ``print(p)`` produced a rather useless summary of our data structure in the example above: + +.. code-block:: python + + >>> print(p) + <example.Pet object at 0x10cd98060> + +To address this, we could bind an utility function that returns a human-readable +summary to the special method slot named ``__repr__``. Unfortunately, there is no +suitable functionality in the ``Pet`` data structure, and it would be nice if +we did not have to change it. This can easily be accomplished by binding a +Lambda function instead: + +.. code-block:: cpp + + py::class_<Pet>(m, "Pet") + .def(py::init<const std::string &>()) + .def("setName", &Pet::setName) + .def("getName", &Pet::getName) + .def("__repr__", + [](const Pet &a) { + return "<example.Pet named '" + a.name + "'>"; + } + ); + +Both stateless [#f1]_ and stateful lambda closures are supported by pybind11. +With the above change, the same Python code now produces the following output: + +.. code-block:: python + + >>> print(p) + <example.Pet named 'Molly'> + +Instance and static fields +========================== + +We can also directly expose the ``name`` field using the +:func:`class_::def_readwrite` method. A similar :func:`class_::def_readonly` +method also exists for ``const`` fields. + +.. code-block:: cpp + + py::class_<Pet>(m, "Pet") + .def(py::init<const std::string &>()) + .def_readwrite("name", &Pet::name) + // ... remainder ... + +This makes it possible to write + +.. code-block:: python + + >>> p = example.Pet('Molly') + >>> p.name + u'Molly' + >>> p.name = 'Charly' + >>> p.name + u'Charly' + +Now suppose that ``Pet::name`` was a private internal variable +that can only be accessed via setters and getters. + +.. code-block:: cpp + + class Pet { + public: + Pet(const std::string &name) : name(name) { } + void setName(const std::string &name_) { name = name_; } + const std::string &getName() const { return name; } + private: + std::string name; + }; + +In this case, the method :func:`class_::def_property` +(:func:`class_::def_property_readonly` for read-only data) can be used to +provide a field-like interface within Python that will transparently call +the setter and getter functions: + +.. code-block:: cpp + + py::class_<Pet>(m, "Pet") + .def(py::init<const std::string &>()) + .def_property("name", &Pet::getName, &Pet::setName) + // ... remainder ... + +.. seealso:: + + Similar functions :func:`class_::def_readwrite_static`, + :func:`class_::def_readonly_static` :func:`class_::def_property_static`, + and :func:`class_::def_property_readonly_static` are provided for binding + static variables and properties. + +.. _inheritance: + +Inheritance +=========== + +Suppose now that the example consists of two data structures with an +inheritance relationship: + +.. code-block:: cpp + + struct Pet { + Pet(const std::string &name) : name(name) { } + std::string name; + }; + + struct Dog : Pet { + Dog(const std::string &name) : Pet(name) { } + std::string bark() const { return "woof!"; } + }; + +There are two different ways of indicating a hierarchical relationship to +pybind11: the first is by specifying the C++ base class explicitly during +construction using the ``base`` attribute: + +.. code-block:: cpp + + py::class_<Pet>(m, "Pet") + .def(py::init<const std::string &>()) + .def_readwrite("name", &Pet::name); + + py::class_<Dog>(m, "Dog", py::base<Pet>() /* <- specify C++ parent type */) + .def(py::init<const std::string &>()) + .def("bark", &Dog::bark); + +Alternatively, we can also assign a name to the previously bound ``Pet`` +:class:`class_` object and reference it when binding the ``Dog`` class: + +.. code-block:: cpp + + py::class_<Pet> pet(m, "Pet"); + pet.def(py::init<const std::string &>()) + .def_readwrite("name", &Pet::name); + + py::class_<Dog>(m, "Dog", pet /* <- specify Python parent type */) + .def(py::init<const std::string &>()) + .def("bark", &Dog::bark); + +Functionality-wise, both approaches are completely equivalent. Afterwards, +instances will expose fields and methods of both types: + +.. code-block:: python + + >>> p = example.Dog('Molly') + >>> p.name + u'Molly' + >>> p.bark() + u'woof!' + +Overloaded methods +================== + +Sometimes there are several overloaded C++ methods with the same name taking +different kinds of input arguments: + +.. code-block:: cpp + + struct Pet { + Pet(const std::string &name, int age) : name(name), age(age) { } + + void set(int age) { age = age; } + void set(const std::string &name) { name = name; } + + std::string name; + int age; + }; + +Attempting to bind ``Pet::set`` will cause an error since the compiler does not +know which method the user intended to select. We can disambiguate by casting +them to function pointers. Binding multiple functions to the same Python name +automatically creates a chain of function overloads that will be tried in +sequence. + +.. code-block:: cpp + + py::class_<Pet>(m, "Pet") + .def(py::init<const std::string &, int>()) + .def("set", (void (Pet::*)(int)) &Pet::set, "Set the pet's age") + .def("set", (void (Pet::*)(const std::string &)) &Pet::set, "Set the pet's name"); + +The overload signatures are also visible in the method's docstring: + +.. code-block:: python + + >>> help(example.Pet) + + class Pet(__builtin__.object) + | Methods defined here: + | + | __init__(...) + | Signature : (Pet, str, int) -> NoneType + | + | set(...) + | 1. Signature : (Pet, int) -> NoneType + | + | Set the pet's age + | + | 2. Signature : (Pet, str) -> NoneType + | + | Set the pet's name + +.. note:: + + To define multiple overloaded constructors, simply declare one after the + other using the ``.def(py::init<...>())`` syntax. The existing machinery + for specifying keyword and default arguments also works. + +Enumerations and internal types +=============================== + +Let's now suppose that the example class contains an internal enumeration type, +e.g.: + +.. code-block:: cpp + + struct Pet { + enum Kind { + Dog = 0, + Cat + }; + + Pet(const std::string &name, Kind type) : name(name), type(type) { } + + std::string name; + Kind type; + }; + +The binding code for this example looks as follows: + +.. code-block:: cpp + + py::class_<Pet> pet(m, "Pet"); + + pet.def(py::init<const std::string &, Pet::Kind>()) + .def_readwrite("name", &Pet::name) + .def_readwrite("type", &Pet::type); + + py::enum_<Pet::Kind>(pet, "Kind") + .value("Dog", Pet::Kind::Dog) + .value("Cat", Pet::Kind::Cat) + .export_values(); + +To ensure that the ``Kind`` type is created within the scope of ``Pet``, the +``pet`` :class:`class_` instance must be supplied to the :class:`enum_`. +constructor. The :func:`enum_::export_values` function exports the enum entries +into the parent scope, which should be skipped for newer C++11-style strongly +typed enums. + +.. code-block:: python + + >>> p = Pet('Lucy', Pet.Cat) + >>> p.type + Kind.Cat + >>> int(p.type) + 1L + + +.. [#f1] Stateless closures are those with an empty pair of brackets ``[]`` as the capture object. diff --git a/stormpy/resources/pybind11/docs/cmake.rst b/stormpy/resources/pybind11/docs/cmake.rst new file mode 100644 index 000000000..ace216758 --- /dev/null +++ b/stormpy/resources/pybind11/docs/cmake.rst @@ -0,0 +1,153 @@ +Build systems +############# + +Building with setuptools +======================== + +For projects on PyPI, building with setuptools is the way to go. Sylvain Corlay +has kindly provided an example project which shows how to set up everything, +including automatic generation of documentation using Sphinx. Please refer to +the [pbtest]_ repository. + +.. [pbtest] https://github.com/pybind/pbtest + +.. _cmake: + +Building with CMake +=================== + +For C++ codebases that already have an existing CMake-based build system, the +following snippet should be a good starting point to create bindings across +platforms. It assumes that the code is located in a file named +:file:`example.cpp`, and that the pybind11 repository is located in a +subdirectory named :file:`pybind11`. + +.. code-block:: cmake + + cmake_minimum_required(VERSION 2.8) + + project(example) + + # Add a CMake parameter for choosing a desired Python version + set(EXAMPLE_PYTHON_VERSION "" CACHE STRING "Python version to use for compiling the example library") + + include(CheckCXXCompilerFlag) + + # Set a default build configuration if none is specified. 'MinSizeRel' produces the smallest binaries + if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + message(STATUS "Setting build type to 'MinSizeRel' as none was specified.") + set(CMAKE_BUILD_TYPE MinSizeRel CACHE STRING "Choose the type of build." FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" + "MinSizeRel" "RelWithDebInfo") + endif() + string(TOUPPER "${CMAKE_BUILD_TYPE}" U_CMAKE_BUILD_TYPE) + + # Try to autodetect Python (can be overridden manually if needed) + set(Python_ADDITIONAL_VERSIONS 3.4 3.5 3.6 3.7) + if (NOT ${EXAMPLE_PYTHON_VERSION} STREQUAL "") + find_package(PythonLibs ${EXAMPLE_PYTHON_VERSION} EXACT) + if (NOT PythonLibs_FOUND) + find_package(PythonLibs ${EXAMPLE_PYTHON_VERSION} REQUIRED) + endif() + else() + find_package(PythonLibs REQUIRED) + endif() + + # The above sometimes returns version numbers like "3.4.3+"; the "+" must be removed for the next lines to work + string(REPLACE "+" "" PYTHONLIBS_VERSION_STRING "+${PYTHONLIBS_VERSION_STRING}") + + # Uncomment the following line if you will also require a matching Python interpreter + # find_package(PythonInterp ${PYTHONLIBS_VERSION_STRING} EXACT REQUIRED) + + if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") + CHECK_CXX_COMPILER_FLAG("-std=c++14" HAS_CPP14_FLAG) + CHECK_CXX_COMPILER_FLAG("-std=c++11" HAS_CPP11_FLAG) + + if (HAS_CPP14_FLAG) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") + elseif (HAS_CPP11_FLAG) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + else() + message(FATAL_ERROR "Unsupported compiler -- at least C++11 support is needed!") + endif() + + # Enable link time optimization and set the default symbol + # visibility to hidden (very important to obtain small binaries) + if (NOT ${U_CMAKE_BUILD_TYPE} MATCHES DEBUG) + # Default symbol visibility + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") + + # Check for Link Time Optimization support + CHECK_CXX_COMPILER_FLAG("-flto" HAS_LTO_FLAG) + if (HAS_LTO_FLAG) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto") + endif() + endif() + endif() + + # Include path for Python header files + include_directories(${PYTHON_INCLUDE_DIR}) + + # Include path for pybind11 header files -- this may need to be changed depending on your setup + include_directories(${PROJECT_SOURCE_DIR}/pybind11/include) + + # Create the binding library + add_library(example SHARED + example.cpp + # ... extra files go here ... + ) + + # Don't add a 'lib' prefix to the shared library + set_target_properties(example PROPERTIES PREFIX "") + + if (WIN32) + if (MSVC) + # /bigobj is needed for bigger binding projects due to the limit to 64k + # addressable sections. /MP enables multithreaded builds (relevant when + # there are many files). + set_target_properties(example PROPERTIES COMPILE_FLAGS "/MP /bigobj ") + + if (NOT ${U_CMAKE_BUILD_TYPE} MATCHES DEBUG) + # Enforce size-based optimization and link time code generation on MSVC + # (~30% smaller binaries in experiments). + set_target_properties(example APPEND_STRING PROPERTY COMPILE_FLAGS "/Os /GL ") + set_target_properties(example APPEND_STRING PROPERTY LINK_FLAGS "/LTCG ") + endif() + endif() + + # .PYD file extension on Windows + set_target_properties(example PROPERTIES SUFFIX ".pyd") + + # Link against the Python shared library + target_link_libraries(example ${PYTHON_LIBRARY}) + elseif (UNIX) + # It's quite common to have multiple copies of the same Python version + # installed on one's system. E.g.: one copy from the OS and another copy + # that's statically linked into an application like Blender or Maya. + # If we link our plugin library against the OS Python here and import it + # into Blender or Maya later on, this will cause segfaults when multiple + # conflicting Python instances are active at the same time (even when they + # are of the same version). + + # Windows is not affected by this issue since it handles DLL imports + # differently. The solution for Linux and Mac OS is simple: we just don't + # link against the Python library. The resulting shared library will have + # missing symbols, but that's perfectly fine -- they will be resolved at + # import time. + + # .SO file extension on Linux/Mac OS + set_target_properties(example PROPERTIES SUFFIX ".so") + + # Strip unnecessary sections of the binary on Linux/Mac OS + if(APPLE) + set_target_properties(example PROPERTIES MACOSX_RPATH ".") + set_target_properties(example PROPERTIES LINK_FLAGS "-undefined dynamic_lookup ") + if (NOT ${U_CMAKE_BUILD_TYPE} MATCHES DEBUG) + add_custom_command(TARGET example POST_BUILD COMMAND strip -u -r ${PROJECT_BINARY_DIR}/example.so) + endif() + else() + if (NOT ${U_CMAKE_BUILD_TYPE} MATCHES DEBUG) + add_custom_command(TARGET example POST_BUILD COMMAND strip ${PROJECT_BINARY_DIR}/example.so) + endif() + endif() + endif() diff --git a/stormpy/resources/pybind11/docs/conf.py b/stormpy/resources/pybind11/docs/conf.py new file mode 100644 index 000000000..a05acc33e --- /dev/null +++ b/stormpy/resources/pybind11/docs/conf.py @@ -0,0 +1,308 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# pybind11 documentation build configuration file, created by +# sphinx-quickstart on Sun Oct 11 19:23:48 2015. +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys +import os +import shlex + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +#sys.path.insert(0, os.path.abspath('.')) + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +#needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['.templates'] + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +# source_suffix = ['.rst', '.md'] +source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = 'pybind11' +copyright = '2015, Wenzel Jakob' +author = 'Wenzel Jakob' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = '1.0' +# The full version, including alpha/beta/rc tags. +release = '1.0' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = ['.build'] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +#pygments_style = 'monokai' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +#keep_warnings = False + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = False + + +# -- Options for HTML output ---------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. + +on_rtd = os.environ.get('READTHEDOCS', None) == 'True' + +if not on_rtd: # only import and set the theme if we're building docs locally + import sphinx_rtd_theme + html_theme = 'sphinx_rtd_theme' + html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] + + html_context = { + 'css_files': [ + '_static/theme_overrides.css' + ] + } +else: + html_context = { + 'css_files': [ + '//media.readthedocs.org/css/sphinx_rtd_theme.css', + '//media.readthedocs.org/css/readthedocs-doc-embed.css', + '_static/theme_overrides.css' + ] + } + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +#html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +#html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# "<project> v<release> documentation". +#html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['.static'] + +# Add any extra paths that contain custom files (such as robots.txt or +# .htaccess) here, relative to this directory. These files are copied +# directly to the root of the documentation. +#html_extra_path = [] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +#html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_domain_indices = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +#html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +#html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a <link> tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = None + +# Language to be used for generating the HTML full-text search index. +# Sphinx supports the following languages: +# 'da', 'de', 'en', 'es', 'fi', 'fr', 'h', 'it', 'ja' +# 'nl', 'no', 'pt', 'ro', 'r', 'sv', 'tr' +#html_search_language = 'en' + +# A dictionary with options for the search language support, empty by default. +# Now only 'ja' uses this config value +#html_search_options = {'type': 'default'} + +# The name of a javascript file (relative to the configuration directory) that +# implements a search results scorer. If empty, the default will be used. +#html_search_scorer = 'scorer.js' + +# Output file base name for HTML help builder. +htmlhelp_basename = 'pybind11doc' + +# -- Options for LaTeX output --------------------------------------------- + +latex_elements = { +# The paper size ('letterpaper' or 'a4paper'). +#'papersize': 'letterpaper', + +# The font size ('10pt', '11pt' or '12pt'). +#'pointsize': '10pt', + +# Additional stuff for the LaTeX preamble. +#'preamble': '', + +# Latex figure (float) alignment +#'figure_align': 'htbp', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + (master_doc, 'pybind11.tex', 'pybind11 Documentation', + 'Wenzel Jakob', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# If true, show page references after internal links. +#latex_show_pagerefs = False + +# If true, show URL addresses after external links. +#latex_show_urls = False + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_domain_indices = True + + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + (master_doc, 'pybind11', 'pybind11 Documentation', + [author], 1) +] + +# If true, show URL addresses after external links. +#man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + (master_doc, 'pybind11', 'pybind11 Documentation', + author, 'pybind11', 'One line description of project.', + 'Miscellaneous'), +] + +# Documents to append as an appendix to all manuals. +#texinfo_appendices = [] + +# If false, no module index is generated. +#texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +#texinfo_show_urls = 'footnote' + +# If true, do not generate a @detailmenu in the "Top" node's menu. +#texinfo_no_detailmenu = False + +primary_domain = 'cpp' +highlight_language = 'cpp' diff --git a/stormpy/resources/pybind11/docs/faq.rst b/stormpy/resources/pybind11/docs/faq.rst new file mode 100644 index 000000000..12d28375e --- /dev/null +++ b/stormpy/resources/pybind11/docs/faq.rst @@ -0,0 +1,99 @@ +Frequently asked questions +########################## + +(under construction) + +ImportError: dynamic module does not define init function +========================================================= + +1. Make sure that the name specified in ``pybind::module`` and + ``PYBIND11_PLUGIN`` is consistent and identical to the filename of the + extension library. The latter should not contain any extra prefixes (e.g. + ``test.so`` instead of ``libtest.so``). + +2. If the above did not fix your issue, then you are likely using an + incompatible version of Python (for instance, the extension library was + compiled against Python 2, while the interpreter is running on top of some + version of Python 3) + +Limitations involving reference arguments +========================================= + +In C++, it's fairly common to pass arguments using mutable references or +mutable pointers, which allows both read and write access to the value +supplied by the caller. This is sometimes done for efficiency reasons, or to +realize functions that have multiple return values. Here are two very basic +examples: + +.. code-block:: cpp + + void increment(int &i) { i++; } + void increment_ptr(int *i) { (*i)++; } + +In Python, all arguments are passed by reference, so there is no general +issue in binding such code from Python. + +However, certain basic Python types (like ``str``, ``int``, ``bool``, +``float``, etc.) are **immutable**. This means that the following attempt +to port the function to Python doesn't have the same effect on the value +provided by the caller -- in fact, it does nothing at all. + +.. code-block:: python + + def increment(i): + i += 1 # nope.. + +pybind11 is also affected by such language-level conventions, which means that +binding ``increment`` or ``increment_ptr`` will also create Python functions +that don't modify their arguments. + +Although inconvenient, one workaround is to encapsulate the immutable types in +a custom type that does allow modifications. + +An other alternative involves binding a small wrapper lambda function that +returns a tuple with all output arguments (see the remainder of the +documentation for examples on binding lambda functions). An example: + +.. code-block:: cpp + + int foo(int &i) { i++; return 123; } + +and the binding code + +.. code-block:: cpp + + m.def("foo", [](int i) { int rv = foo(i); return std::make_tuple(rv, i); }); + +CMake doesn't detect the right Python version, or it finds mismatched interpreter and library versions +====================================================================================================== + +The Python detection logic of CMake is flawed and can sometimes fail to find +the desired Python version, or it chooses mismatched interpreter and library +versions. A longer discussion is available on the pybind11 issue tracker +[#f1]_, though this is ultimately not a pybind11 issue. + +To force the build system to choose a particular version, delete CMakeCache.txt +and then invoke CMake as follows: + +.. code-block:: bash + + cmake -DPYTHON_EXECUTABLE:FILEPATH=<...> \ + -DPYTHON_LIBRARY:FILEPATH=<...> \ + -DPYTHON_INCLUDE_DIR:PATH=<...> . + +.. [#f1] http://github.com/pybind/pybind11/issues/99 + +Working with ancient Visual Studio 2009 builds on Windows +========================================================= + +The official Windows distributions of Python are compiled using truly +ancient versions of Visual Studio that lack good C++11 support. Some users +implicitly assume that it would be impossible to load a plugin built with +Visual Studio 2015 into a Python distribution that was compiled using Visual +Studio 2009. However, no such issue exists: it's perfectly legitimate to +interface DLLs that are built with different compilers and/or C libraries. +Common gotchas to watch out for involve not ``free()``-ing memory region +that that were ``malloc()``-ed in another shared library, using data +structures with incompatible ABIs, and so on. pybind11 is very careful not +to make these types of mistakes. + diff --git a/stormpy/resources/pybind11/docs/index.rst b/stormpy/resources/pybind11/docs/index.rst new file mode 100644 index 000000000..56a9c0cfa --- /dev/null +++ b/stormpy/resources/pybind11/docs/index.rst @@ -0,0 +1,20 @@ +.. image:: pybind11-logo.png + +pybind11 --- Seamless operability between C++11 and Python +========================================================== + +Contents: + +.. toctree:: + :maxdepth: 2 + + intro + basics + classes + advanced + cmake + benchmark + limitations + faq + reference + changelog diff --git a/stormpy/resources/pybind11/docs/intro.rst b/stormpy/resources/pybind11/docs/intro.rst new file mode 100644 index 000000000..af35db9eb --- /dev/null +++ b/stormpy/resources/pybind11/docs/intro.rst @@ -0,0 +1,87 @@ +.. image:: pybind11-logo.png + +About this project +================== +**pybind11** is a lightweight header-only library that exposes C++ types in Python +and vice versa, mainly to create Python bindings of existing C++ code. Its +goals and syntax are similar to the excellent `Boost.Python`_ library by David +Abrahams: to minimize boilerplate code in traditional extension modules by +inferring type information using compile-time introspection. + +.. _Boost.Python: http://www.boost.org/doc/libs/release/libs/python/doc/index.html + +The main issue with Boost.Python—and the reason for creating such a similar +project—is Boost. Boost is an enormously large and complex suite of utility +libraries that works with almost every C++ compiler in existence. This +compatibility has its cost: arcane template tricks and workarounds are +necessary to support the oldest and buggiest of compiler specimens. Now that +C++11-compatible compilers are widely available, this heavy machinery has +become an excessively large and unnecessary dependency. + +Think of this library as a tiny self-contained version of Boost.Python with +everything stripped away that isn't relevant for binding generation. Without +comments, the core header files only require ~2.5K lines of code and depend on +Python (2.7 or 3.x) and the C++ standard library. This compact implementation +was possible thanks to some of the new C++11 language features (specifically: +tuples, lambda functions and variadic templates). Since its creation, this +library has grown beyond Boost.Python in many ways, leading to dramatically +simpler binding code in many common situations. + +Core features +************* +The following core C++ features can be mapped to Python + +- Functions accepting and returning custom data structures per value, reference, or pointer +- Instance methods and static methods +- Overloaded functions +- Instance attributes and static attributes +- Exceptions +- Enumerations +- Iterators and ranges +- Callbacks +- Custom operators +- STL data structures +- Smart pointers with reference counting like ``std::shared_ptr`` +- Internal references with correct reference counting +- C++ classes with virtual (and pure virtual) methods can be extended in Python + +Goodies +******* +In addition to the core functionality, pybind11 provides some extra goodies: + +- It is possible to bind C++11 lambda functions with captured variables. The + lambda capture data is stored inside the resulting Python function object. + +- pybind11 uses C++11 move constructors and move assignment operators whenever + possible to efficiently transfer custom data types. + +- It's easy to expose the internal storage of custom data types through + Pythons' buffer protocols. This is handy e.g. for fast conversion between + C++ matrix classes like Eigen and NumPy without expensive copy operations. + +- pybind11 can automatically vectorize functions so that they are transparently + applied to all entries of one or more NumPy array arguments. + +- Python's slice-based access and assignment operations can be supported with + just a few lines of code. + +- Everything is contained in just a few header files; there is no need to link + against any additional libraries. + +- Binaries are generally smaller by a factor of 2 or more compared to + equivalent bindings generated by Boost.Python. + +- When supported by the compiler, two new C++14 features (relaxed constexpr and + return value deduction) are used to precompute function signatures at compile + time, leading to smaller binaries. + +- With little extra effort, C++ types can be pickled and unpickled similar to + regular Python objects. + +Supported compilers +******************* + +1. Clang/LLVM (any non-ancient version with C++11 support) +2. GCC (any non-ancient version with C++11 support) +3. Microsoft Visual Studio 2015 or newer +4. Intel C++ compiler v15 or newer diff --git a/stormpy/resources/pybind11/docs/limitations.rst b/stormpy/resources/pybind11/docs/limitations.rst new file mode 100644 index 000000000..434d09b37 --- /dev/null +++ b/stormpy/resources/pybind11/docs/limitations.rst @@ -0,0 +1,19 @@ +Limitations +########### + +pybind11 strives to be a general solution to binding generation, but it also has +certain limitations: + +- pybind11 casts away ``const``-ness in function arguments and return values. + This is in line with the Python language, which has no concept of ``const`` + values. This means that some additional care is needed to avoid bugs that + would be caught by the type checker in a traditional C++ program. + +- Multiple inheritance relationships on the C++ side cannot be mapped to + Python. + +Both of these features could be implemented but would lead to a significant +increase in complexity. I've decided to draw the line here to keep this project +simple and compact. Users who absolutely require these features are encouraged +to fork pybind11. + diff --git a/stormpy/resources/pybind11/docs/pybind11-logo.png b/stormpy/resources/pybind11/docs/pybind11-logo.png new file mode 100644 index 000000000..4cbad54f7 Binary files /dev/null and b/stormpy/resources/pybind11/docs/pybind11-logo.png differ diff --git a/stormpy/resources/pybind11/docs/pybind11_vs_boost_python1.svg b/stormpy/resources/pybind11/docs/pybind11_vs_boost_python1.svg new file mode 100644 index 000000000..5bf950e6f --- /dev/null +++ b/stormpy/resources/pybind11/docs/pybind11_vs_boost_python1.svg @@ -0,0 +1,427 @@ +<?xml version="1.0" encoding="UTF-8"?> +<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="468pt" height="252pt" viewBox="0 0 468 252" version="1.1"> +<defs> +<g> +<symbol overflow="visible" id="glyph0-0"> +<path style="stroke:none;" d=""/> +</symbol> +<symbol overflow="visible" id="glyph0-1"> +<path style="stroke:none;" d="M 3.726562 0 L 2.847656 0 L 2.847656 -5.601562 C 2.636719 -5.398438 2.359375 -5.195312 2.015625 -4.996094 C 1.671875 -4.792969 1.363281 -4.640625 1.089844 -4.539062 L 1.089844 -5.390625 C 1.582031 -5.621094 2.011719 -5.902344 2.378906 -6.230469 C 2.746094 -6.558594 3.007812 -6.878906 3.160156 -7.1875 L 3.726562 -7.1875 Z "/> +</symbol> +<symbol overflow="visible" id="glyph0-2"> +<path style="stroke:none;" d="M 0.414062 -3.53125 C 0.414062 -4.375 0.503906 -5.058594 0.675781 -5.574219 C 0.851562 -6.089844 1.109375 -6.488281 1.453125 -6.765625 C 1.796875 -7.046875 2.226562 -7.1875 2.75 -7.1875 C 3.132812 -7.1875 3.46875 -7.109375 3.757812 -6.957031 C 4.046875 -6.800781 4.289062 -6.578125 4.476562 -6.285156 C 4.664062 -5.996094 4.8125 -5.640625 4.921875 -5.222656 C 5.03125 -4.804688 5.082031 -4.238281 5.082031 -3.53125 C 5.082031 -2.691406 4.996094 -2.011719 4.824219 -1.496094 C 4.652344 -0.980469 4.394531 -0.582031 4.050781 -0.300781 C 3.707031 -0.0195312 3.273438 0.121094 2.75 0.121094 C 2.058594 0.121094 1.515625 -0.125 1.125 -0.621094 C 0.652344 -1.214844 0.414062 -2.1875 0.414062 -3.53125 Z M 1.320312 -3.53125 C 1.320312 -2.355469 1.457031 -1.574219 1.730469 -1.183594 C 2.007812 -0.796875 2.34375 -0.601562 2.75 -0.601562 C 3.152344 -0.601562 3.492188 -0.796875 3.765625 -1.1875 C 4.042969 -1.578125 4.179688 -2.359375 4.179688 -3.53125 C 4.179688 -4.710938 4.042969 -5.492188 3.765625 -5.878906 C 3.492188 -6.265625 3.148438 -6.460938 2.738281 -6.460938 C 2.335938 -6.460938 2.011719 -6.289062 1.773438 -5.945312 C 1.46875 -5.511719 1.320312 -4.707031 1.320312 -3.53125 Z "/> +</symbol> +<symbol overflow="visible" id="glyph0-3"> +<path style="stroke:none;" d="M 5.035156 -0.84375 L 5.035156 0 L 0.304688 0 C 0.296875 -0.210938 0.332031 -0.414062 0.40625 -0.609375 C 0.527344 -0.933594 0.71875 -1.25 0.984375 -1.5625 C 1.25 -1.875 1.632812 -2.234375 2.132812 -2.648438 C 2.910156 -3.285156 3.4375 -3.789062 3.710938 -4.164062 C 3.984375 -4.535156 4.121094 -4.886719 4.121094 -5.21875 C 4.121094 -5.566406 3.996094 -5.863281 3.746094 -6.101562 C 3.5 -6.339844 3.171875 -6.460938 2.773438 -6.460938 C 2.351562 -6.460938 2.011719 -6.332031 1.757812 -6.078125 C 1.503906 -5.824219 1.375 -5.472656 1.371094 -5.023438 L 0.46875 -5.117188 C 0.53125 -5.789062 0.761719 -6.304688 1.167969 -6.65625 C 1.570312 -7.011719 2.113281 -7.1875 2.792969 -7.1875 C 3.480469 -7.1875 4.023438 -6.996094 4.421875 -6.617188 C 4.824219 -6.234375 5.023438 -5.761719 5.023438 -5.199219 C 5.023438 -4.914062 4.964844 -4.632812 4.847656 -4.355469 C 4.730469 -4.078125 4.535156 -3.789062 4.265625 -3.480469 C 3.992188 -3.175781 3.542969 -2.753906 2.910156 -2.222656 C 2.382812 -1.78125 2.042969 -1.480469 1.894531 -1.320312 C 1.746094 -1.164062 1.621094 -1.003906 1.523438 -0.84375 Z "/> +</symbol> +<symbol overflow="visible" id="glyph0-4"> +<path style="stroke:none;" d="M 0.414062 -1.875 L 1.335938 -1.953125 C 1.40625 -1.503906 1.566406 -1.167969 1.8125 -0.941406 C 2.0625 -0.714844 2.363281 -0.601562 2.714844 -0.601562 C 3.136719 -0.601562 3.496094 -0.761719 3.789062 -1.078125 C 4.082031 -1.398438 4.226562 -1.820312 4.226562 -2.347656 C 4.226562 -2.851562 4.085938 -3.246094 3.804688 -3.535156 C 3.523438 -3.824219 3.15625 -3.96875 2.699219 -3.96875 C 2.417969 -3.96875 2.160156 -3.90625 1.933594 -3.777344 C 1.707031 -3.648438 1.527344 -3.480469 1.398438 -3.277344 L 0.570312 -3.382812 L 1.265625 -7.0625 L 4.824219 -7.0625 L 4.824219 -6.21875 L 1.96875 -6.21875 L 1.582031 -4.296875 C 2.011719 -4.597656 2.460938 -4.746094 2.933594 -4.746094 C 3.558594 -4.746094 4.085938 -4.53125 4.515625 -4.097656 C 4.945312 -3.664062 5.160156 -3.105469 5.160156 -2.425781 C 5.160156 -1.777344 4.972656 -1.21875 4.59375 -0.746094 C 4.136719 -0.167969 3.507812 0.121094 2.714844 0.121094 C 2.0625 0.121094 1.53125 -0.0585938 1.121094 -0.425781 C 0.710938 -0.789062 0.472656 -1.273438 0.414062 -1.875 Z "/> +</symbol> +<symbol overflow="visible" id="glyph0-5"> +<path style="stroke:none;" d="M 0.820312 0 L 0.820312 -7.15625 L 5.648438 -7.15625 L 5.648438 -6.3125 L 1.765625 -6.3125 L 1.765625 -4.097656 L 5.125 -4.097656 L 5.125 -3.25 L 1.765625 -3.25 L 1.765625 0 Z "/> +</symbol> +<symbol overflow="visible" id="glyph0-6"> +<path style="stroke:none;" d="M 4.058594 0 L 4.058594 -0.761719 C 3.65625 -0.175781 3.105469 0.117188 2.414062 0.117188 C 2.105469 0.117188 1.820312 0.0585938 1.554688 -0.0585938 C 1.289062 -0.175781 1.09375 -0.324219 0.964844 -0.5 C 0.835938 -0.679688 0.746094 -0.894531 0.695312 -1.152344 C 0.65625 -1.324219 0.640625 -1.597656 0.640625 -1.972656 L 0.640625 -5.1875 L 1.519531 -5.1875 L 1.519531 -2.308594 C 1.519531 -1.851562 1.535156 -1.542969 1.570312 -1.382812 C 1.625 -1.152344 1.746094 -0.96875 1.921875 -0.835938 C 2.101562 -0.703125 2.324219 -0.640625 2.585938 -0.640625 C 2.851562 -0.640625 3.097656 -0.707031 3.328125 -0.84375 C 3.5625 -0.976562 3.726562 -1.160156 3.820312 -1.394531 C 3.917969 -1.625 3.964844 -1.964844 3.964844 -2.40625 L 3.964844 -5.1875 L 4.84375 -5.1875 L 4.84375 0 Z "/> +</symbol> +<symbol overflow="visible" id="glyph0-7"> +<path style="stroke:none;" d="M 0.660156 0 L 0.660156 -5.1875 L 1.449219 -5.1875 L 1.449219 -4.449219 C 1.832031 -5.019531 2.382812 -5.304688 3.101562 -5.304688 C 3.414062 -5.304688 3.699219 -5.246094 3.960938 -5.132812 C 4.222656 -5.023438 4.421875 -4.875 4.550781 -4.691406 C 4.679688 -4.507812 4.773438 -4.292969 4.824219 -4.042969 C 4.855469 -3.878906 4.875 -3.59375 4.875 -3.1875 L 4.875 0 L 3.992188 0 L 3.992188 -3.15625 C 3.992188 -3.511719 3.960938 -3.78125 3.890625 -3.957031 C 3.824219 -4.132812 3.703125 -4.277344 3.527344 -4.382812 C 3.351562 -4.488281 3.148438 -4.539062 2.914062 -4.539062 C 2.539062 -4.539062 2.21875 -4.421875 1.945312 -4.183594 C 1.671875 -3.945312 1.539062 -3.496094 1.539062 -2.832031 L 1.539062 0 Z "/> +</symbol> +<symbol overflow="visible" id="glyph0-8"> +<path style="stroke:none;" d="M 4.042969 -1.898438 L 4.90625 -1.789062 C 4.8125 -1.191406 4.570312 -0.726562 4.183594 -0.386719 C 3.792969 -0.0507812 3.316406 0.117188 2.75 0.117188 C 2.039062 0.117188 1.46875 -0.113281 1.039062 -0.578125 C 0.605469 -1.042969 0.390625 -1.707031 0.390625 -2.574219 C 0.390625 -3.132812 0.484375 -3.625 0.667969 -4.042969 C 0.855469 -4.460938 1.136719 -4.777344 1.515625 -4.988281 C 1.894531 -5.199219 2.308594 -5.304688 2.753906 -5.304688 C 3.316406 -5.304688 3.777344 -5.160156 4.136719 -4.875 C 4.492188 -4.589844 4.722656 -4.1875 4.824219 -3.664062 L 3.96875 -3.53125 C 3.886719 -3.878906 3.746094 -4.140625 3.539062 -4.316406 C 3.332031 -4.492188 3.082031 -4.578125 2.789062 -4.578125 C 2.34375 -4.578125 1.984375 -4.421875 1.710938 -4.105469 C 1.433594 -3.789062 1.292969 -3.285156 1.292969 -2.597656 C 1.292969 -1.902344 1.425781 -1.394531 1.695312 -1.078125 C 1.960938 -0.761719 2.308594 -0.605469 2.738281 -0.605469 C 3.085938 -0.605469 3.371094 -0.710938 3.601562 -0.921875 C 3.835938 -1.132812 3.980469 -1.460938 4.042969 -1.898438 Z "/> +</symbol> +<symbol overflow="visible" id="glyph0-9"> +<path style="stroke:none;" d="M 2.578125 -0.785156 L 2.703125 -0.0078125 C 2.457031 0.0429688 2.234375 0.0703125 2.039062 0.0703125 C 1.722656 0.0703125 1.476562 0.0195312 1.296875 -0.0820312 C 1.121094 -0.183594 1 -0.316406 0.929688 -0.480469 C 0.855469 -0.644531 0.820312 -0.992188 0.820312 -1.519531 L 0.820312 -4.5 L 0.175781 -4.5 L 0.175781 -5.1875 L 0.820312 -5.1875 L 0.820312 -6.46875 L 1.695312 -6.996094 L 1.695312 -5.1875 L 2.578125 -5.1875 L 2.578125 -4.5 L 1.695312 -4.5 L 1.695312 -1.46875 C 1.695312 -1.21875 1.710938 -1.058594 1.742188 -0.984375 C 1.773438 -0.914062 1.820312 -0.859375 1.890625 -0.816406 C 1.960938 -0.773438 2.0625 -0.75 2.191406 -0.75 C 2.289062 -0.75 2.417969 -0.761719 2.578125 -0.785156 Z "/> +</symbol> +<symbol overflow="visible" id="glyph0-10"> +<path style="stroke:none;" d="M 0.664062 -6.148438 L 0.664062 -7.15625 L 1.542969 -7.15625 L 1.542969 -6.148438 Z M 0.664062 0 L 0.664062 -5.1875 L 1.542969 -5.1875 L 1.542969 0 Z "/> +</symbol> +<symbol overflow="visible" id="glyph0-11"> +<path style="stroke:none;" d="M 0.332031 -2.59375 C 0.332031 -3.554688 0.597656 -4.265625 1.132812 -4.726562 C 1.578125 -5.109375 2.121094 -5.304688 2.765625 -5.304688 C 3.476562 -5.304688 4.058594 -5.070312 4.511719 -4.601562 C 4.964844 -4.132812 5.191406 -3.488281 5.191406 -2.664062 C 5.191406 -2 5.089844 -1.472656 4.890625 -1.089844 C 4.691406 -0.707031 4.398438 -0.410156 4.015625 -0.199219 C 3.632812 0.0117188 3.214844 0.117188 2.765625 0.117188 C 2.039062 0.117188 1.449219 -0.117188 1.003906 -0.582031 C 0.554688 -1.046875 0.332031 -1.71875 0.332031 -2.59375 Z M 1.234375 -2.59375 C 1.234375 -1.929688 1.378906 -1.429688 1.671875 -1.101562 C 1.960938 -0.769531 2.324219 -0.605469 2.765625 -0.605469 C 3.199219 -0.605469 3.5625 -0.773438 3.851562 -1.101562 C 4.140625 -1.433594 4.289062 -1.941406 4.289062 -2.621094 C 4.289062 -3.261719 4.140625 -3.75 3.851562 -4.078125 C 3.558594 -4.410156 3.195312 -4.574219 2.765625 -4.574219 C 2.324219 -4.574219 1.960938 -4.410156 1.671875 -4.082031 C 1.382812 -3.753906 1.234375 -3.257812 1.234375 -2.59375 Z "/> +</symbol> +<symbol overflow="visible" id="glyph0-12"> +<path style="stroke:none;" d="M 0.308594 -1.546875 L 1.175781 -1.683594 C 1.226562 -1.335938 1.363281 -1.070312 1.585938 -0.882812 C 1.808594 -0.699219 2.117188 -0.605469 2.519531 -0.605469 C 2.921875 -0.605469 3.222656 -0.6875 3.417969 -0.851562 C 3.613281 -1.015625 3.710938 -1.210938 3.710938 -1.429688 C 3.710938 -1.628906 3.625 -1.785156 3.453125 -1.898438 C 3.332031 -1.976562 3.03125 -2.078125 2.554688 -2.195312 C 1.910156 -2.359375 1.460938 -2.5 1.214844 -2.621094 C 0.964844 -2.738281 0.777344 -2.902344 0.648438 -3.113281 C 0.519531 -3.324219 0.453125 -3.554688 0.453125 -3.808594 C 0.453125 -4.039062 0.507812 -4.253906 0.613281 -4.449219 C 0.71875 -4.648438 0.863281 -4.8125 1.046875 -4.941406 C 1.183594 -5.042969 1.367188 -5.128906 1.605469 -5.199219 C 1.839844 -5.269531 2.09375 -5.304688 2.363281 -5.304688 C 2.769531 -5.304688 3.128906 -5.242188 3.433594 -5.125 C 3.742188 -5.007812 3.96875 -4.851562 4.117188 -4.652344 C 4.261719 -4.453125 4.363281 -4.183594 4.417969 -3.847656 L 3.558594 -3.730469 C 3.519531 -3.996094 3.40625 -4.207031 3.21875 -4.355469 C 3.03125 -4.503906 2.769531 -4.578125 2.425781 -4.578125 C 2.023438 -4.578125 1.734375 -4.511719 1.5625 -4.378906 C 1.390625 -4.246094 1.304688 -4.089844 1.304688 -3.910156 C 1.304688 -3.796875 1.339844 -3.695312 1.410156 -3.601562 C 1.484375 -3.507812 1.59375 -3.429688 1.75 -3.367188 C 1.835938 -3.335938 2.09375 -3.261719 2.523438 -3.144531 C 3.144531 -2.976562 3.578125 -2.84375 3.824219 -2.738281 C 4.070312 -2.632812 4.265625 -2.476562 4.40625 -2.273438 C 4.546875 -2.074219 4.613281 -1.824219 4.613281 -1.523438 C 4.613281 -1.230469 4.527344 -0.953125 4.359375 -0.695312 C 4.1875 -0.4375 3.941406 -0.238281 3.617188 -0.09375 C 3.296875 0.046875 2.929688 0.117188 2.523438 0.117188 C 1.851562 0.117188 1.335938 -0.0234375 0.984375 -0.304688 C 0.632812 -0.582031 0.40625 -0.996094 0.308594 -1.546875 Z "/> +</symbol> +<symbol overflow="visible" id="glyph1-0"> +<path style="stroke:none;" d=""/> +</symbol> +<symbol overflow="visible" id="glyph1-1"> +<path style="stroke:none;" d="M -2.300781 -0.449219 L -2.378906 -1.34375 C -2.019531 -1.386719 -1.726562 -1.484375 -1.496094 -1.636719 C -1.265625 -1.792969 -1.082031 -2.03125 -0.941406 -2.359375 C -0.796875 -2.683594 -0.726562 -3.050781 -0.726562 -3.457031 C -0.726562 -3.820312 -0.78125 -4.136719 -0.890625 -4.414062 C -0.996094 -4.691406 -1.144531 -4.898438 -1.332031 -5.03125 C -1.519531 -5.167969 -1.722656 -5.234375 -1.945312 -5.234375 C -2.167969 -5.234375 -2.363281 -5.167969 -2.53125 -5.039062 C -2.699219 -4.910156 -2.839844 -4.695312 -2.953125 -4.394531 C -3.027344 -4.203125 -3.144531 -3.777344 -3.304688 -3.121094 C -3.460938 -2.460938 -3.609375 -2 -3.75 -1.738281 C -3.929688 -1.398438 -4.152344 -1.140625 -4.417969 -0.972656 C -4.683594 -0.804688 -4.980469 -0.722656 -5.308594 -0.722656 C -5.667969 -0.722656 -6.007812 -0.824219 -6.320312 -1.03125 C -6.632812 -1.234375 -6.875 -1.535156 -7.035156 -1.929688 C -7.199219 -2.324219 -7.28125 -2.761719 -7.28125 -3.242188 C -7.28125 -3.773438 -7.195312 -4.242188 -7.023438 -4.644531 C -6.851562 -5.050781 -6.601562 -5.363281 -6.269531 -5.582031 C -5.9375 -5.800781 -5.5625 -5.917969 -5.140625 -5.933594 L -5.074219 -5.023438 C -5.527344 -4.976562 -5.867188 -4.808594 -6.097656 -4.527344 C -6.328125 -4.246094 -6.445312 -3.832031 -6.445312 -3.28125 C -6.445312 -2.707031 -6.339844 -2.289062 -6.128906 -2.027344 C -5.921875 -1.765625 -5.667969 -1.636719 -5.371094 -1.636719 C -5.113281 -1.636719 -4.902344 -1.726562 -4.734375 -1.914062 C -4.570312 -2.097656 -4.398438 -2.574219 -4.226562 -3.34375 C -4.050781 -4.113281 -3.898438 -4.640625 -3.769531 -4.925781 C -3.578125 -5.34375 -3.335938 -5.652344 -3.039062 -5.851562 C -2.746094 -6.046875 -2.40625 -6.148438 -2.023438 -6.148438 C -1.640625 -6.148438 -1.28125 -6.039062 -0.945312 -5.820312 C -0.609375 -5.601562 -0.347656 -5.289062 -0.160156 -4.878906 C 0.0273438 -4.472656 0.121094 -4.011719 0.121094 -3.5 C 0.121094 -2.851562 0.0273438 -2.308594 -0.160156 -1.871094 C -0.351562 -1.433594 -0.632812 -1.089844 -1.011719 -0.84375 C -1.390625 -0.59375 -1.820312 -0.460938 -2.300781 -0.449219 Z "/> +</symbol> +<symbol overflow="visible" id="glyph1-2"> +<path style="stroke:none;" d="M -1.671875 -4.210938 L -1.558594 -5.117188 C -1.027344 -4.972656 -0.617188 -4.707031 -0.320312 -4.320312 C -0.0273438 -3.933594 0.117188 -3.4375 0.117188 -2.835938 C 0.117188 -2.078125 -0.117188 -1.476562 -0.582031 -1.03125 C -1.050781 -0.585938 -1.707031 -0.367188 -2.546875 -0.367188 C -3.421875 -0.367188 -4.097656 -0.589844 -4.578125 -1.039062 C -5.0625 -1.488281 -5.304688 -2.070312 -5.304688 -2.789062 C -5.304688 -3.480469 -5.066406 -4.046875 -4.59375 -4.488281 C -4.121094 -4.925781 -3.457031 -5.148438 -2.601562 -5.148438 C -2.550781 -5.148438 -2.472656 -5.144531 -2.367188 -5.140625 L -2.367188 -1.273438 C -1.796875 -1.304688 -1.363281 -1.46875 -1.058594 -1.757812 C -0.757812 -2.046875 -0.605469 -2.410156 -0.605469 -2.84375 C -0.605469 -3.164062 -0.691406 -3.4375 -0.859375 -3.667969 C -1.027344 -3.894531 -1.296875 -4.074219 -1.671875 -4.210938 Z M -3.089844 -1.324219 L -3.089844 -4.21875 C -3.527344 -4.179688 -3.855469 -4.070312 -4.070312 -3.886719 C -4.410156 -3.605469 -4.578125 -3.242188 -4.578125 -2.796875 C -4.578125 -2.394531 -4.445312 -2.054688 -4.175781 -1.78125 C -3.90625 -1.503906 -3.542969 -1.351562 -3.089844 -1.324219 Z "/> +</symbol> +<symbol overflow="visible" id="glyph1-3"> +<path style="stroke:none;" d="M -1.898438 -4.042969 L -1.789062 -4.90625 C -1.191406 -4.8125 -0.726562 -4.570312 -0.386719 -4.183594 C -0.0507812 -3.792969 0.117188 -3.316406 0.117188 -2.75 C 0.117188 -2.039062 -0.113281 -1.46875 -0.578125 -1.039062 C -1.042969 -0.605469 -1.707031 -0.390625 -2.574219 -0.390625 C -3.132812 -0.390625 -3.625 -0.484375 -4.042969 -0.667969 C -4.460938 -0.855469 -4.777344 -1.136719 -4.988281 -1.515625 C -5.199219 -1.894531 -5.304688 -2.308594 -5.304688 -2.753906 C -5.304688 -3.316406 -5.160156 -3.777344 -4.875 -4.136719 C -4.589844 -4.492188 -4.1875 -4.722656 -3.664062 -4.824219 L -3.53125 -3.96875 C -3.878906 -3.886719 -4.140625 -3.746094 -4.316406 -3.539062 C -4.492188 -3.332031 -4.578125 -3.082031 -4.578125 -2.789062 C -4.578125 -2.34375 -4.421875 -1.984375 -4.105469 -1.710938 C -3.789062 -1.433594 -3.285156 -1.292969 -2.597656 -1.292969 C -1.902344 -1.292969 -1.394531 -1.425781 -1.078125 -1.695312 C -0.761719 -1.960938 -0.605469 -2.308594 -0.605469 -2.738281 C -0.605469 -3.085938 -0.710938 -3.371094 -0.921875 -3.601562 C -1.132812 -3.835938 -1.460938 -3.980469 -1.898438 -4.042969 Z "/> +</symbol> +<symbol overflow="visible" id="glyph1-4"> +<path style="stroke:none;" d="M -2.59375 -0.332031 C -3.554688 -0.332031 -4.265625 -0.597656 -4.726562 -1.132812 C -5.109375 -1.578125 -5.304688 -2.121094 -5.304688 -2.765625 C -5.304688 -3.476562 -5.070312 -4.058594 -4.601562 -4.511719 C -4.132812 -4.964844 -3.488281 -5.191406 -2.664062 -5.191406 C -2 -5.191406 -1.472656 -5.089844 -1.089844 -4.890625 C -0.707031 -4.691406 -0.410156 -4.398438 -0.199219 -4.015625 C 0.0117188 -3.632812 0.117188 -3.214844 0.117188 -2.765625 C 0.117188 -2.039062 -0.117188 -1.449219 -0.582031 -1.003906 C -1.046875 -0.554688 -1.71875 -0.332031 -2.59375 -0.332031 Z M -2.59375 -1.234375 C -1.929688 -1.234375 -1.429688 -1.378906 -1.101562 -1.671875 C -0.769531 -1.960938 -0.605469 -2.324219 -0.605469 -2.765625 C -0.605469 -3.199219 -0.773438 -3.5625 -1.101562 -3.851562 C -1.433594 -4.140625 -1.941406 -4.289062 -2.621094 -4.289062 C -3.261719 -4.289062 -3.75 -4.140625 -4.078125 -3.851562 C -4.410156 -3.558594 -4.574219 -3.195312 -4.574219 -2.765625 C -4.574219 -2.324219 -4.410156 -1.960938 -4.082031 -1.671875 C -3.753906 -1.382812 -3.257812 -1.234375 -2.59375 -1.234375 Z "/> +</symbol> +<symbol overflow="visible" id="glyph1-5"> +<path style="stroke:none;" d="M 0 -0.660156 L -5.1875 -0.660156 L -5.1875 -1.449219 L -4.449219 -1.449219 C -5.019531 -1.832031 -5.304688 -2.382812 -5.304688 -3.101562 C -5.304688 -3.414062 -5.246094 -3.699219 -5.132812 -3.960938 C -5.023438 -4.222656 -4.875 -4.421875 -4.691406 -4.550781 C -4.507812 -4.679688 -4.292969 -4.773438 -4.042969 -4.824219 C -3.878906 -4.855469 -3.59375 -4.875 -3.1875 -4.875 L 0 -4.875 L 0 -3.992188 L -3.15625 -3.992188 C -3.511719 -3.992188 -3.78125 -3.960938 -3.957031 -3.890625 C -4.132812 -3.824219 -4.277344 -3.703125 -4.382812 -3.527344 C -4.488281 -3.351562 -4.539062 -3.148438 -4.539062 -2.914062 C -4.539062 -2.539062 -4.421875 -2.21875 -4.183594 -1.945312 C -3.945312 -1.671875 -3.496094 -1.539062 -2.832031 -1.539062 L 0 -1.539062 Z "/> +</symbol> +<symbol overflow="visible" id="glyph1-6"> +<path style="stroke:none;" d="M 0 -4.023438 L -0.65625 -4.023438 C -0.140625 -3.695312 0.117188 -3.210938 0.117188 -2.574219 C 0.117188 -2.160156 0.00390625 -1.78125 -0.226562 -1.433594 C -0.453125 -1.085938 -0.769531 -0.816406 -1.179688 -0.628906 C -1.585938 -0.4375 -2.058594 -0.34375 -2.585938 -0.34375 C -3.105469 -0.34375 -3.574219 -0.429688 -3.996094 -0.601562 C -4.417969 -0.773438 -4.742188 -1.03125 -4.964844 -1.375 C -5.191406 -1.722656 -5.304688 -2.109375 -5.304688 -2.535156 C -5.304688 -2.847656 -5.238281 -3.125 -5.105469 -3.367188 C -4.972656 -3.613281 -4.800781 -3.8125 -4.589844 -3.964844 L -7.15625 -3.964844 L -7.15625 -4.839844 L 0 -4.839844 Z M -2.585938 -1.246094 C -1.921875 -1.246094 -1.425781 -1.386719 -1.097656 -1.664062 C -0.769531 -1.945312 -0.605469 -2.273438 -0.605469 -2.65625 C -0.605469 -3.039062 -0.761719 -3.367188 -1.078125 -3.636719 C -1.390625 -3.90625 -1.871094 -4.039062 -2.515625 -4.039062 C -3.226562 -4.039062 -3.746094 -3.902344 -4.078125 -3.628906 C -4.410156 -3.355469 -4.574219 -3.015625 -4.574219 -2.617188 C -4.574219 -2.226562 -4.414062 -1.898438 -4.097656 -1.636719 C -3.777344 -1.375 -3.273438 -1.246094 -2.585938 -1.246094 Z "/> +</symbol> +<symbol overflow="visible" id="glyph1-7"> +<path style="stroke:none;" d="M -1.546875 -0.308594 L -1.683594 -1.175781 C -1.335938 -1.226562 -1.070312 -1.363281 -0.882812 -1.585938 C -0.699219 -1.808594 -0.605469 -2.117188 -0.605469 -2.519531 C -0.605469 -2.921875 -0.6875 -3.222656 -0.851562 -3.417969 C -1.015625 -3.613281 -1.210938 -3.710938 -1.429688 -3.710938 C -1.628906 -3.710938 -1.785156 -3.625 -1.898438 -3.453125 C -1.976562 -3.332031 -2.078125 -3.03125 -2.195312 -2.554688 C -2.359375 -1.910156 -2.5 -1.460938 -2.621094 -1.214844 C -2.738281 -0.964844 -2.902344 -0.777344 -3.113281 -0.648438 C -3.324219 -0.519531 -3.554688 -0.453125 -3.808594 -0.453125 C -4.039062 -0.453125 -4.253906 -0.507812 -4.449219 -0.613281 C -4.648438 -0.71875 -4.8125 -0.863281 -4.941406 -1.046875 C -5.042969 -1.183594 -5.128906 -1.367188 -5.199219 -1.605469 C -5.269531 -1.839844 -5.304688 -2.09375 -5.304688 -2.363281 C -5.304688 -2.769531 -5.242188 -3.128906 -5.125 -3.433594 C -5.007812 -3.742188 -4.851562 -3.96875 -4.652344 -4.117188 C -4.453125 -4.261719 -4.183594 -4.363281 -3.847656 -4.417969 L -3.730469 -3.558594 C -3.996094 -3.519531 -4.207031 -3.40625 -4.355469 -3.21875 C -4.503906 -3.03125 -4.578125 -2.769531 -4.578125 -2.425781 C -4.578125 -2.023438 -4.511719 -1.734375 -4.378906 -1.5625 C -4.246094 -1.390625 -4.089844 -1.304688 -3.910156 -1.304688 C -3.796875 -1.304688 -3.695312 -1.339844 -3.601562 -1.410156 C -3.507812 -1.484375 -3.429688 -1.59375 -3.367188 -1.75 C -3.335938 -1.835938 -3.261719 -2.09375 -3.144531 -2.523438 C -2.976562 -3.144531 -2.84375 -3.578125 -2.738281 -3.824219 C -2.632812 -4.070312 -2.476562 -4.265625 -2.273438 -4.40625 C -2.074219 -4.546875 -1.824219 -4.613281 -1.523438 -4.613281 C -1.230469 -4.613281 -0.953125 -4.527344 -0.695312 -4.359375 C -0.4375 -4.1875 -0.238281 -3.941406 -0.09375 -3.617188 C 0.046875 -3.296875 0.117188 -2.929688 0.117188 -2.523438 C 0.117188 -1.851562 -0.0234375 -1.335938 -0.304688 -0.984375 C -0.582031 -0.632812 -0.996094 -0.40625 -1.546875 -0.308594 Z "/> +</symbol> +<symbol overflow="visible" id="glyph2-0"> +<path style="stroke:none;" d=""/> +</symbol> +<symbol overflow="visible" id="glyph2-1"> +<path style="stroke:none;" d="M 7.054688 -3.011719 L 8.191406 -2.726562 C 7.953125 -1.792969 7.523438 -1.078125 6.90625 -0.589844 C 6.285156 -0.0976562 5.53125 0.148438 4.632812 0.148438 C 3.707031 0.148438 2.957031 -0.0429688 2.375 -0.417969 C 1.796875 -0.796875 1.355469 -1.34375 1.050781 -2.054688 C 0.75 -2.769531 0.597656 -3.539062 0.597656 -4.359375 C 0.597656 -5.253906 0.769531 -6.035156 1.109375 -6.699219 C 1.453125 -7.367188 1.9375 -7.871094 2.570312 -8.21875 C 3.199219 -8.5625 3.894531 -8.734375 4.652344 -8.734375 C 5.511719 -8.734375 6.234375 -8.515625 6.820312 -8.078125 C 7.40625 -7.640625 7.8125 -7.027344 8.046875 -6.234375 L 6.925781 -5.96875 C 6.726562 -6.59375 6.4375 -7.050781 6.058594 -7.335938 C 5.679688 -7.621094 5.203125 -7.765625 4.628906 -7.765625 C 3.96875 -7.765625 3.417969 -7.605469 2.972656 -7.289062 C 2.53125 -6.972656 2.21875 -6.546875 2.039062 -6.015625 C 1.859375 -5.480469 1.769531 -4.929688 1.769531 -4.367188 C 1.769531 -3.636719 1.875 -2.996094 2.089844 -2.453125 C 2.300781 -1.90625 2.632812 -1.5 3.082031 -1.230469 C 3.53125 -0.960938 4.015625 -0.828125 4.539062 -0.828125 C 5.175781 -0.828125 5.71875 -1.007812 6.15625 -1.375 C 6.597656 -1.742188 6.898438 -2.289062 7.054688 -3.011719 Z "/> +</symbol> +<symbol overflow="visible" id="glyph2-2"> +<path style="stroke:none;" d="M 0.398438 -3.109375 C 0.398438 -4.261719 0.71875 -5.117188 1.359375 -5.671875 C 1.894531 -6.132812 2.546875 -6.363281 3.316406 -6.363281 C 4.171875 -6.363281 4.871094 -6.082031 5.414062 -5.523438 C 5.957031 -4.960938 6.226562 -4.1875 6.226562 -3.199219 C 6.226562 -2.398438 6.109375 -1.769531 5.867188 -1.308594 C 5.628906 -0.851562 5.277344 -0.492188 4.820312 -0.242188 C 4.359375 0.0117188 3.859375 0.140625 3.316406 0.140625 C 2.445312 0.140625 1.742188 -0.140625 1.203125 -0.695312 C 0.667969 -1.253906 0.398438 -2.0625 0.398438 -3.109375 Z M 1.484375 -3.109375 C 1.484375 -2.3125 1.65625 -1.71875 2.003906 -1.320312 C 2.351562 -0.925781 2.789062 -0.726562 3.316406 -0.726562 C 3.839844 -0.726562 4.273438 -0.925781 4.625 -1.324219 C 4.972656 -1.722656 5.144531 -2.328125 5.144531 -3.148438 C 5.144531 -3.917969 4.96875 -4.5 4.621094 -4.894531 C 4.269531 -5.292969 3.835938 -5.492188 3.316406 -5.492188 C 2.789062 -5.492188 2.351562 -5.292969 2.003906 -4.898438 C 1.65625 -4.503906 1.484375 -3.90625 1.484375 -3.109375 Z "/> +</symbol> +<symbol overflow="visible" id="glyph2-3"> +<path style="stroke:none;" d="M 0.789062 0 L 0.789062 -6.222656 L 1.734375 -6.222656 L 1.734375 -5.351562 C 1.929688 -5.65625 2.1875 -5.898438 2.515625 -6.085938 C 2.839844 -6.269531 3.207031 -6.363281 3.621094 -6.363281 C 4.082031 -6.363281 4.460938 -6.265625 4.753906 -6.078125 C 5.050781 -5.886719 5.257812 -5.617188 5.378906 -5.273438 C 5.871094 -6 6.511719 -6.363281 7.300781 -6.363281 C 7.917969 -6.363281 8.390625 -6.191406 8.726562 -5.851562 C 9.058594 -5.507812 9.222656 -4.984375 9.222656 -4.273438 L 9.222656 0 L 8.171875 0 L 8.171875 -3.921875 C 8.171875 -4.34375 8.140625 -4.644531 8.070312 -4.832031 C 8.003906 -5.015625 7.878906 -5.164062 7.699219 -5.28125 C 7.519531 -5.394531 7.308594 -5.449219 7.066406 -5.449219 C 6.628906 -5.449219 6.265625 -5.304688 5.976562 -5.011719 C 5.6875 -4.722656 5.542969 -4.257812 5.542969 -3.617188 L 5.542969 0 L 4.488281 0 L 4.488281 -4.042969 C 4.488281 -4.511719 4.402344 -4.863281 4.230469 -5.097656 C 4.058594 -5.332031 3.777344 -5.449219 3.386719 -5.449219 C 3.089844 -5.449219 2.816406 -5.371094 2.5625 -5.214844 C 2.3125 -5.058594 2.128906 -4.828125 2.015625 -4.53125 C 1.902344 -4.230469 1.84375 -3.796875 1.84375 -3.226562 L 1.84375 0 Z "/> +</symbol> +<symbol overflow="visible" id="glyph2-4"> +<path style="stroke:none;" d="M 0.789062 2.382812 L 0.789062 -6.222656 L 1.75 -6.222656 L 1.75 -5.414062 C 1.976562 -5.730469 2.234375 -5.96875 2.519531 -6.125 C 2.804688 -6.285156 3.148438 -6.363281 3.554688 -6.363281 C 4.085938 -6.363281 4.554688 -6.226562 4.960938 -5.953125 C 5.367188 -5.679688 5.675781 -5.292969 5.882812 -4.796875 C 6.089844 -4.296875 6.195312 -3.75 6.195312 -3.15625 C 6.195312 -2.519531 6.078125 -1.949219 5.851562 -1.4375 C 5.621094 -0.929688 5.289062 -0.539062 4.855469 -0.265625 C 4.417969 0.00390625 3.960938 0.140625 3.480469 0.140625 C 3.128906 0.140625 2.8125 0.0664062 2.535156 -0.0820312 C 2.253906 -0.230469 2.023438 -0.417969 1.84375 -0.644531 L 1.84375 2.382812 Z M 1.746094 -3.078125 C 1.746094 -2.277344 1.90625 -1.683594 2.234375 -1.300781 C 2.558594 -0.917969 2.949219 -0.726562 3.410156 -0.726562 C 3.878906 -0.726562 4.28125 -0.925781 4.613281 -1.320312 C 4.949219 -1.71875 5.117188 -2.332031 5.117188 -3.164062 C 5.117188 -3.957031 4.953125 -4.550781 4.625 -4.945312 C 4.300781 -5.339844 3.910156 -5.539062 3.457031 -5.539062 C 3.007812 -5.539062 2.609375 -5.328125 2.265625 -4.90625 C 1.917969 -4.488281 1.746094 -3.875 1.746094 -3.078125 Z "/> +</symbol> +<symbol overflow="visible" id="glyph2-5"> +<path style="stroke:none;" d="M 0.796875 -7.375 L 0.796875 -8.589844 L 1.851562 -8.589844 L 1.851562 -7.375 Z M 0.796875 0 L 0.796875 -6.222656 L 1.851562 -6.222656 L 1.851562 0 Z "/> +</symbol> +<symbol overflow="visible" id="glyph2-6"> +<path style="stroke:none;" d="M 0.765625 0 L 0.765625 -8.589844 L 1.820312 -8.589844 L 1.820312 0 Z "/> +</symbol> +<symbol overflow="visible" id="glyph2-7"> +<path style="stroke:none;" d="M 4.851562 -0.765625 C 4.460938 -0.433594 4.085938 -0.203125 3.722656 -0.0625 C 3.363281 0.0742188 2.976562 0.140625 2.5625 0.140625 C 1.878906 0.140625 1.351562 -0.0273438 0.984375 -0.359375 C 0.617188 -0.695312 0.433594 -1.121094 0.433594 -1.640625 C 0.433594 -1.945312 0.503906 -2.222656 0.640625 -2.476562 C 0.78125 -2.726562 0.960938 -2.929688 1.1875 -3.082031 C 1.410156 -3.234375 1.664062 -3.351562 1.945312 -3.429688 C 2.152344 -3.484375 2.464844 -3.535156 2.882812 -3.585938 C 3.734375 -3.6875 4.359375 -3.808594 4.765625 -3.949219 C 4.769531 -4.09375 4.769531 -4.1875 4.769531 -4.226562 C 4.769531 -4.65625 4.671875 -4.957031 4.46875 -5.132812 C 4.199219 -5.371094 3.800781 -5.492188 3.269531 -5.492188 C 2.773438 -5.492188 2.40625 -5.402344 2.171875 -5.230469 C 1.933594 -5.054688 1.757812 -4.75 1.648438 -4.304688 L 0.617188 -4.445312 C 0.710938 -4.886719 0.863281 -5.246094 1.078125 -5.515625 C 1.292969 -5.789062 1.601562 -5.996094 2.007812 -6.144531 C 2.414062 -6.289062 2.886719 -6.363281 3.421875 -6.363281 C 3.953125 -6.363281 4.382812 -6.300781 4.71875 -6.175781 C 5.050781 -6.050781 5.292969 -5.894531 5.449219 -5.703125 C 5.605469 -5.515625 5.714844 -5.273438 5.777344 -4.984375 C 5.8125 -4.804688 5.828125 -4.484375 5.828125 -4.015625 L 5.828125 -2.609375 C 5.828125 -1.628906 5.851562 -1.007812 5.898438 -0.746094 C 5.941406 -0.488281 6.03125 -0.238281 6.164062 0 L 5.0625 0 C 4.953125 -0.21875 4.882812 -0.476562 4.851562 -0.765625 Z M 4.765625 -3.125 C 4.382812 -2.96875 3.804688 -2.835938 3.039062 -2.726562 C 2.605469 -2.664062 2.300781 -2.59375 2.121094 -2.515625 C 1.941406 -2.4375 1.804688 -2.320312 1.703125 -2.171875 C 1.605469 -2.019531 1.558594 -1.851562 1.558594 -1.671875 C 1.558594 -1.390625 1.664062 -1.15625 1.878906 -0.96875 C 2.089844 -0.78125 2.402344 -0.6875 2.8125 -0.6875 C 3.21875 -0.6875 3.578125 -0.773438 3.898438 -0.953125 C 4.214844 -1.128906 4.445312 -1.375 4.59375 -1.679688 C 4.707031 -1.917969 4.765625 -2.273438 4.765625 -2.734375 Z "/> +</symbol> +<symbol overflow="visible" id="glyph2-8"> +<path style="stroke:none;" d="M 3.09375 -0.945312 L 3.246094 -0.0117188 C 2.949219 0.0507812 2.683594 0.0820312 2.449219 0.0820312 C 2.066406 0.0820312 1.769531 0.0234375 1.558594 -0.101562 C 1.347656 -0.222656 1.199219 -0.378906 1.113281 -0.578125 C 1.027344 -0.773438 0.984375 -1.1875 0.984375 -1.820312 L 0.984375 -5.402344 L 0.210938 -5.402344 L 0.210938 -6.222656 L 0.984375 -6.222656 L 0.984375 -7.765625 L 2.03125 -8.398438 L 2.03125 -6.222656 L 3.09375 -6.222656 L 3.09375 -5.402344 L 2.03125 -5.402344 L 2.03125 -1.765625 C 2.03125 -1.464844 2.050781 -1.269531 2.089844 -1.183594 C 2.125 -1.097656 2.1875 -1.03125 2.269531 -0.976562 C 2.355469 -0.925781 2.476562 -0.902344 2.632812 -0.902344 C 2.75 -0.902344 2.902344 -0.914062 3.09375 -0.945312 Z "/> +</symbol> +<symbol overflow="visible" id="glyph2-9"> +<path style="stroke:none;" d="M 0.789062 0 L 0.789062 -6.222656 L 1.742188 -6.222656 L 1.742188 -5.335938 C 2.199219 -6.019531 2.859375 -6.363281 3.71875 -6.363281 C 4.09375 -6.363281 4.441406 -6.296875 4.753906 -6.160156 C 5.070312 -6.027344 5.304688 -5.851562 5.460938 -5.632812 C 5.617188 -5.414062 5.726562 -5.152344 5.789062 -4.851562 C 5.828125 -4.65625 5.847656 -4.3125 5.847656 -3.828125 L 5.847656 0 L 4.792969 0 L 4.792969 -3.785156 C 4.792969 -4.214844 4.75 -4.535156 4.671875 -4.75 C 4.589844 -4.960938 4.441406 -5.132812 4.234375 -5.257812 C 4.023438 -5.386719 3.78125 -5.449219 3.5 -5.449219 C 3.050781 -5.449219 2.660156 -5.304688 2.335938 -5.023438 C 2.007812 -4.738281 1.84375 -4.195312 1.84375 -3.398438 L 1.84375 0 Z "/> +</symbol> +<symbol overflow="visible" id="glyph2-10"> +<path style="stroke:none;" d="M 5.050781 -2.003906 L 6.140625 -1.867188 C 5.96875 -1.230469 5.648438 -0.738281 5.1875 -0.386719 C 4.722656 -0.0351562 4.125 0.140625 3.40625 0.140625 C 2.496094 0.140625 1.773438 -0.140625 1.238281 -0.699219 C 0.707031 -1.261719 0.4375 -2.046875 0.4375 -3.058594 C 0.4375 -4.105469 0.710938 -4.917969 1.25 -5.496094 C 1.789062 -6.074219 2.484375 -6.363281 3.34375 -6.363281 C 4.175781 -6.363281 4.859375 -6.078125 5.382812 -5.515625 C 5.910156 -4.949219 6.175781 -4.148438 6.175781 -3.125 C 6.175781 -3.0625 6.171875 -2.96875 6.171875 -2.84375 L 1.53125 -2.84375 C 1.570312 -2.160156 1.761719 -1.632812 2.109375 -1.273438 C 2.457031 -0.910156 2.890625 -0.726562 3.410156 -0.726562 C 3.796875 -0.726562 4.125 -0.828125 4.398438 -1.03125 C 4.671875 -1.234375 4.890625 -1.558594 5.050781 -2.003906 Z M 1.585938 -3.710938 L 5.0625 -3.710938 C 5.015625 -4.234375 4.882812 -4.625 4.664062 -4.886719 C 4.328125 -5.292969 3.890625 -5.496094 3.359375 -5.496094 C 2.875 -5.496094 2.464844 -5.335938 2.136719 -5.007812 C 1.804688 -4.683594 1.625 -4.25 1.585938 -3.710938 Z "/> +</symbol> +<symbol overflow="visible" id="glyph2-11"> +<path style="stroke:none;" d="M 1.042969 0 L 1.042969 -5.402344 L 0.109375 -5.402344 L 0.109375 -6.222656 L 1.042969 -6.222656 L 1.042969 -6.882812 C 1.042969 -7.300781 1.078125 -7.613281 1.15625 -7.816406 C 1.257812 -8.089844 1.433594 -8.3125 1.691406 -8.480469 C 1.945312 -8.652344 2.304688 -8.734375 2.765625 -8.734375 C 3.0625 -8.734375 3.390625 -8.703125 3.75 -8.632812 L 3.59375 -7.710938 C 3.375 -7.75 3.164062 -7.769531 2.96875 -7.769531 C 2.648438 -7.769531 2.421875 -7.703125 2.289062 -7.5625 C 2.15625 -7.425781 2.09375 -7.171875 2.09375 -6.796875 L 2.09375 -6.222656 L 3.304688 -6.222656 L 3.304688 -5.402344 L 2.09375 -5.402344 L 2.09375 0 Z "/> +</symbol> +<symbol overflow="visible" id="glyph2-12"> +<path style="stroke:none;" d="M 4.828125 0 L 4.828125 -0.785156 C 4.433594 -0.167969 3.851562 0.140625 3.085938 0.140625 C 2.589844 0.140625 2.136719 0.00390625 1.71875 -0.269531 C 1.304688 -0.542969 0.980469 -0.925781 0.753906 -1.414062 C 0.523438 -1.90625 0.410156 -2.46875 0.410156 -3.105469 C 0.410156 -3.726562 0.515625 -4.289062 0.71875 -4.796875 C 0.925781 -5.300781 1.238281 -5.6875 1.652344 -5.960938 C 2.066406 -6.230469 2.53125 -6.363281 3.039062 -6.363281 C 3.414062 -6.363281 3.75 -6.285156 4.042969 -6.125 C 4.335938 -5.96875 4.574219 -5.761719 4.757812 -5.507812 L 4.757812 -8.589844 L 5.804688 -8.589844 L 5.804688 0 Z M 1.492188 -3.105469 C 1.492188 -2.308594 1.664062 -1.710938 2 -1.320312 C 2.335938 -0.925781 2.730469 -0.726562 3.1875 -0.726562 C 3.648438 -0.726562 4.039062 -0.914062 4.363281 -1.292969 C 4.683594 -1.667969 4.84375 -2.242188 4.84375 -3.015625 C 4.84375 -3.867188 4.679688 -4.492188 4.351562 -4.890625 C 4.023438 -5.289062 3.621094 -5.492188 3.140625 -5.492188 C 2.671875 -5.492188 2.28125 -5.296875 1.964844 -4.914062 C 1.652344 -4.53125 1.492188 -3.929688 1.492188 -3.105469 Z "/> +</symbol> +<symbol overflow="visible" id="glyph2-13"> +<path style="stroke:none;" d="M 4.867188 0 L 4.867188 -0.914062 C 4.382812 -0.210938 3.726562 0.140625 2.894531 0.140625 C 2.527344 0.140625 2.183594 0.0703125 1.867188 -0.0703125 C 1.546875 -0.210938 1.3125 -0.386719 1.15625 -0.601562 C 1.003906 -0.8125 0.894531 -1.074219 0.832031 -1.382812 C 0.789062 -1.589844 0.765625 -1.917969 0.765625 -2.367188 L 0.765625 -6.222656 L 1.820312 -6.222656 L 1.820312 -2.773438 C 1.820312 -2.222656 1.84375 -1.851562 1.886719 -1.65625 C 1.953125 -1.378906 2.09375 -1.164062 2.308594 -1.003906 C 2.523438 -0.847656 2.789062 -0.765625 3.105469 -0.765625 C 3.421875 -0.765625 3.71875 -0.847656 3.996094 -1.011719 C 4.273438 -1.171875 4.46875 -1.394531 4.585938 -1.671875 C 4.699219 -1.953125 4.757812 -2.359375 4.757812 -2.890625 L 4.757812 -6.222656 L 5.8125 -6.222656 L 5.8125 0 Z "/> +</symbol> +<symbol overflow="visible" id="glyph3-0"> +<path style="stroke:none;" d=""/> +</symbol> +<symbol overflow="visible" id="glyph3-1"> +<path style="stroke:none;" d="M 0.953125 0 L 0.953125 -9.304688 L 4.445312 -9.304688 C 5.15625 -9.304688 5.722656 -9.210938 6.152344 -9.023438 C 6.582031 -8.835938 6.921875 -8.546875 7.164062 -8.152344 C 7.40625 -7.761719 7.527344 -7.351562 7.527344 -6.925781 C 7.527344 -6.527344 7.421875 -6.152344 7.203125 -5.800781 C 6.988281 -5.449219 6.664062 -5.167969 6.226562 -4.953125 C 6.789062 -4.785156 7.222656 -4.503906 7.523438 -4.105469 C 7.828125 -3.707031 7.980469 -3.238281 7.980469 -2.699219 C 7.980469 -2.261719 7.886719 -1.855469 7.703125 -1.480469 C 7.519531 -1.105469 7.292969 -0.820312 7.019531 -0.617188 C 6.75 -0.414062 6.410156 -0.257812 6 -0.15625 C 5.59375 -0.0507812 5.09375 0 4.5 0 Z M 2.183594 -5.394531 L 4.195312 -5.394531 C 4.742188 -5.394531 5.132812 -5.429688 5.371094 -5.503906 C 5.683594 -5.597656 5.917969 -5.75 6.078125 -5.96875 C 6.238281 -6.183594 6.316406 -6.453125 6.316406 -6.78125 C 6.316406 -7.089844 6.242188 -7.359375 6.09375 -7.59375 C 5.945312 -7.828125 5.734375 -7.992188 5.460938 -8.078125 C 5.183594 -8.164062 4.710938 -8.207031 4.042969 -8.207031 L 2.183594 -8.207031 Z M 2.183594 -1.097656 L 4.5 -1.097656 C 4.898438 -1.097656 5.175781 -1.113281 5.339844 -1.140625 C 5.621094 -1.191406 5.859375 -1.277344 6.050781 -1.398438 C 6.242188 -1.515625 6.394531 -1.6875 6.519531 -1.914062 C 6.640625 -2.140625 6.703125 -2.402344 6.703125 -2.699219 C 6.703125 -3.046875 6.613281 -3.347656 6.4375 -3.601562 C 6.257812 -3.859375 6.011719 -4.039062 5.695312 -4.140625 C 5.382812 -4.246094 4.929688 -4.296875 4.335938 -4.296875 L 2.183594 -4.296875 Z "/> +</symbol> +<symbol overflow="visible" id="glyph3-2"> +<path style="stroke:none;" d="M 0.429688 -3.371094 C 0.429688 -4.617188 0.777344 -5.542969 1.472656 -6.144531 C 2.050781 -6.644531 2.757812 -6.894531 3.59375 -6.894531 C 4.519531 -6.894531 5.277344 -6.589844 5.867188 -5.984375 C 6.453125 -5.375 6.746094 -4.535156 6.746094 -3.464844 C 6.746094 -2.597656 6.617188 -1.914062 6.355469 -1.417969 C 6.097656 -0.921875 5.71875 -0.535156 5.222656 -0.261719 C 4.722656 0.015625 4.179688 0.152344 3.59375 0.152344 C 2.648438 0.152344 1.886719 -0.148438 1.304688 -0.753906 C 0.722656 -1.359375 0.429688 -2.230469 0.429688 -3.371094 Z M 1.605469 -3.371094 C 1.605469 -2.507812 1.792969 -1.859375 2.171875 -1.429688 C 2.546875 -1 3.023438 -0.789062 3.59375 -0.789062 C 4.160156 -0.789062 4.632812 -1.003906 5.007812 -1.433594 C 5.382812 -1.867188 5.574219 -2.523438 5.574219 -3.410156 C 5.574219 -4.242188 5.382812 -4.875 5.003906 -5.304688 C 4.625 -5.734375 4.15625 -5.949219 3.59375 -5.949219 C 3.023438 -5.949219 2.546875 -5.734375 2.171875 -5.304688 C 1.792969 -4.878906 1.605469 -4.234375 1.605469 -3.371094 Z "/> +</symbol> +<symbol overflow="visible" id="glyph3-3"> +<path style="stroke:none;" d="M 0.398438 -2.011719 L 1.53125 -2.191406 C 1.59375 -1.738281 1.769531 -1.390625 2.058594 -1.148438 C 2.347656 -0.90625 2.753906 -0.789062 3.273438 -0.789062 C 3.800781 -0.789062 4.1875 -0.894531 4.445312 -1.109375 C 4.699219 -1.320312 4.824219 -1.570312 4.824219 -1.859375 C 4.824219 -2.117188 4.710938 -2.320312 4.488281 -2.46875 C 4.332031 -2.570312 3.941406 -2.699219 3.320312 -2.855469 C 2.480469 -3.066406 1.902344 -3.25 1.578125 -3.40625 C 1.253906 -3.558594 1.007812 -3.773438 0.839844 -4.046875 C 0.671875 -4.320312 0.589844 -4.621094 0.589844 -4.953125 C 0.589844 -5.253906 0.660156 -5.53125 0.796875 -5.785156 C 0.933594 -6.042969 1.121094 -6.253906 1.359375 -6.421875 C 1.535156 -6.554688 1.777344 -6.667969 2.085938 -6.757812 C 2.390625 -6.847656 2.722656 -6.894531 3.070312 -6.894531 C 3.601562 -6.894531 4.066406 -6.816406 4.464844 -6.664062 C 4.867188 -6.511719 5.160156 -6.304688 5.351562 -6.046875 C 5.542969 -5.785156 5.671875 -5.4375 5.746094 -5 L 4.628906 -4.851562 C 4.578125 -5.195312 4.429688 -5.46875 4.1875 -5.664062 C 3.945312 -5.859375 3.597656 -5.953125 3.15625 -5.953125 C 2.628906 -5.953125 2.253906 -5.867188 2.03125 -5.695312 C 1.808594 -5.519531 1.695312 -5.316406 1.695312 -5.085938 C 1.695312 -4.9375 1.742188 -4.804688 1.835938 -4.683594 C 1.929688 -4.5625 2.074219 -4.460938 2.273438 -4.378906 C 2.386719 -4.335938 2.722656 -4.242188 3.28125 -4.085938 C 4.089844 -3.871094 4.652344 -3.695312 4.972656 -3.558594 C 5.292969 -3.421875 5.542969 -3.21875 5.726562 -2.957031 C 5.90625 -2.695312 6 -2.371094 6 -1.980469 C 6 -1.601562 5.886719 -1.242188 5.664062 -0.90625 C 5.441406 -0.570312 5.121094 -0.308594 4.703125 -0.125 C 4.285156 0.0585938 3.8125 0.152344 3.28125 0.152344 C 2.40625 0.152344 1.738281 -0.03125 1.277344 -0.394531 C 0.820312 -0.757812 0.527344 -1.296875 0.398438 -2.011719 Z "/> +</symbol> +<symbol overflow="visible" id="glyph3-4"> +<path style="stroke:none;" d="M 3.351562 -1.023438 L 3.515625 -0.0117188 C 3.195312 0.0546875 2.90625 0.0898438 2.652344 0.0898438 C 2.238281 0.0898438 1.917969 0.0234375 1.6875 -0.109375 C 1.460938 -0.238281 1.300781 -0.410156 1.207031 -0.625 C 1.113281 -0.839844 1.066406 -1.289062 1.066406 -1.972656 L 1.066406 -5.851562 L 0.226562 -5.851562 L 0.226562 -6.742188 L 1.066406 -6.742188 L 1.066406 -8.410156 L 2.203125 -9.097656 L 2.203125 -6.742188 L 3.351562 -6.742188 L 3.351562 -5.851562 L 2.203125 -5.851562 L 2.203125 -1.910156 C 2.203125 -1.585938 2.222656 -1.375 2.261719 -1.28125 C 2.304688 -1.1875 2.367188 -1.113281 2.460938 -1.058594 C 2.550781 -1.003906 2.679688 -0.976562 2.851562 -0.976562 C 2.976562 -0.976562 3.144531 -0.992188 3.351562 -1.023438 Z "/> +</symbol> +<symbol overflow="visible" id="glyph3-5"> +<path style="stroke:none;" d="M 1.179688 0 L 1.179688 -1.300781 L 2.480469 -1.300781 L 2.480469 0 Z "/> +</symbol> +<symbol overflow="visible" id="glyph3-6"> +<path style="stroke:none;" d="M 1.003906 0 L 1.003906 -9.304688 L 4.511719 -9.304688 C 5.128906 -9.304688 5.601562 -9.277344 5.929688 -9.21875 C 6.386719 -9.140625 6.769531 -8.996094 7.078125 -8.78125 C 7.386719 -8.566406 7.636719 -8.269531 7.824219 -7.882812 C 8.011719 -7.5 8.105469 -7.074219 8.105469 -6.613281 C 8.105469 -5.824219 7.855469 -5.152344 7.351562 -4.605469 C 6.847656 -4.058594 5.9375 -3.78125 4.621094 -3.78125 L 2.234375 -3.78125 L 2.234375 0 Z M 2.234375 -4.882812 L 4.640625 -4.882812 C 5.4375 -4.882812 6 -5.03125 6.335938 -5.324219 C 6.667969 -5.621094 6.835938 -6.039062 6.835938 -6.578125 C 6.835938 -6.964844 6.738281 -7.296875 6.542969 -7.574219 C 6.34375 -7.851562 6.085938 -8.035156 5.765625 -8.125 C 5.558594 -8.179688 5.171875 -8.207031 4.613281 -8.207031 L 2.234375 -8.207031 Z "/> +</symbol> +<symbol overflow="visible" id="glyph3-7"> +<path style="stroke:none;" d="M 0.804688 2.597656 L 0.679688 1.523438 C 0.929688 1.589844 1.148438 1.625 1.332031 1.625 C 1.585938 1.625 1.789062 1.582031 1.941406 1.5 C 2.09375 1.414062 2.21875 1.296875 2.316406 1.140625 C 2.390625 1.027344 2.503906 0.746094 2.664062 0.292969 C 2.6875 0.230469 2.722656 0.136719 2.765625 0.0117188 L 0.210938 -6.742188 L 1.441406 -6.742188 L 2.84375 -2.835938 C 3.027344 -2.34375 3.1875 -1.820312 3.332031 -1.277344 C 3.464844 -1.800781 3.621094 -2.3125 3.800781 -2.8125 L 5.242188 -6.742188 L 6.386719 -6.742188 L 3.820312 0.113281 C 3.546875 0.855469 3.332031 1.363281 3.179688 1.644531 C 2.976562 2.019531 2.746094 2.296875 2.480469 2.472656 C 2.21875 2.648438 1.90625 2.734375 1.542969 2.734375 C 1.324219 2.734375 1.078125 2.6875 0.804688 2.597656 Z "/> +</symbol> +<symbol overflow="visible" id="glyph3-8"> +<path style="stroke:none;" d="M 0.855469 0 L 0.855469 -9.304688 L 2 -9.304688 L 2 -5.96875 C 2.53125 -6.585938 3.207031 -6.894531 4.019531 -6.894531 C 4.519531 -6.894531 4.953125 -6.796875 5.320312 -6.597656 C 5.6875 -6.402344 5.949219 -6.128906 6.109375 -5.78125 C 6.269531 -5.433594 6.347656 -4.933594 6.347656 -4.273438 L 6.347656 0 L 5.203125 0 L 5.203125 -4.273438 C 5.203125 -4.84375 5.082031 -5.257812 4.832031 -5.519531 C 4.585938 -5.78125 4.234375 -5.910156 3.78125 -5.910156 C 3.445312 -5.910156 3.125 -5.820312 2.828125 -5.644531 C 2.53125 -5.46875 2.316406 -5.234375 2.191406 -4.933594 C 2.0625 -4.632812 2 -4.21875 2 -3.6875 L 2 0 Z "/> +</symbol> +<symbol overflow="visible" id="glyph3-9"> +<path style="stroke:none;" d="M 0.855469 0 L 0.855469 -6.742188 L 1.886719 -6.742188 L 1.886719 -5.78125 C 2.382812 -6.523438 3.09375 -6.894531 4.03125 -6.894531 C 4.4375 -6.894531 4.808594 -6.820312 5.152344 -6.675781 C 5.492188 -6.527344 5.746094 -6.335938 5.914062 -6.101562 C 6.085938 -5.863281 6.203125 -5.582031 6.273438 -5.257812 C 6.3125 -5.046875 6.335938 -4.675781 6.335938 -4.144531 L 6.335938 0 L 5.191406 0 L 5.191406 -4.101562 C 5.191406 -4.566406 5.148438 -4.914062 5.058594 -5.144531 C 4.96875 -5.375 4.8125 -5.558594 4.585938 -5.695312 C 4.359375 -5.835938 4.09375 -5.902344 3.789062 -5.902344 C 3.304688 -5.902344 2.882812 -5.75 2.53125 -5.441406 C 2.175781 -5.132812 2 -4.546875 2 -3.679688 L 2 0 Z "/> +</symbol> +<symbol overflow="visible" id="glyph3-10"> +<path style="stroke:none;" d="M 0.855469 2.582031 L 0.855469 -6.742188 L 1.898438 -6.742188 L 1.898438 -5.867188 C 2.144531 -6.207031 2.421875 -6.464844 2.730469 -6.636719 C 3.039062 -6.808594 3.414062 -6.894531 3.851562 -6.894531 C 4.429688 -6.894531 4.9375 -6.746094 5.375 -6.449219 C 5.816406 -6.152344 6.148438 -5.734375 6.375 -5.195312 C 6.597656 -4.65625 6.710938 -4.066406 6.710938 -3.421875 C 6.710938 -2.730469 6.585938 -2.109375 6.339844 -1.558594 C 6.089844 -1.007812 5.730469 -0.582031 5.257812 -0.289062 C 4.785156 0.00390625 4.289062 0.152344 3.769531 0.152344 C 3.390625 0.152344 3.046875 0.0703125 2.746094 -0.0898438 C 2.441406 -0.25 2.195312 -0.453125 2 -0.699219 L 2 2.582031 Z M 1.890625 -3.332031 C 1.890625 -2.464844 2.066406 -1.824219 2.417969 -1.410156 C 2.769531 -0.996094 3.195312 -0.789062 3.695312 -0.789062 C 4.203125 -0.789062 4.636719 -1 5 -1.429688 C 5.359375 -1.859375 5.542969 -2.527344 5.542969 -3.429688 C 5.542969 -4.289062 5.363281 -4.929688 5.011719 -5.359375 C 4.65625 -5.785156 4.234375 -6 3.746094 -6 C 3.257812 -6 2.828125 -5.769531 2.453125 -5.316406 C 2.078125 -4.859375 1.890625 -4.199219 1.890625 -3.332031 Z "/> +</symbol> +<symbol overflow="visible" id="glyph3-11"> +<path style="stroke:none;" d="M 1.910156 0 L 0.851562 0 L 0.851562 -9.304688 L 1.992188 -9.304688 L 1.992188 -5.984375 C 2.476562 -6.589844 3.089844 -6.894531 3.839844 -6.894531 C 4.253906 -6.894531 4.648438 -6.808594 5.019531 -6.644531 C 5.390625 -6.476562 5.691406 -6.242188 5.933594 -5.9375 C 6.171875 -5.636719 6.359375 -5.269531 6.492188 -4.84375 C 6.628906 -4.414062 6.695312 -3.957031 6.695312 -3.472656 C 6.695312 -2.316406 6.410156 -1.425781 5.839844 -0.792969 C 5.269531 -0.164062 4.582031 0.152344 3.78125 0.152344 C 2.988281 0.152344 2.363281 -0.179688 1.910156 -0.84375 Z M 1.898438 -3.421875 C 1.898438 -2.613281 2.007812 -2.027344 2.226562 -1.667969 C 2.585938 -1.082031 3.074219 -0.789062 3.6875 -0.789062 C 4.1875 -0.789062 4.617188 -1.003906 4.984375 -1.4375 C 5.347656 -1.871094 5.527344 -2.519531 5.527344 -3.375 C 5.527344 -4.257812 5.355469 -4.90625 5.003906 -5.324219 C 4.65625 -5.742188 4.234375 -5.953125 3.738281 -5.953125 C 3.238281 -5.953125 2.808594 -5.738281 2.445312 -5.304688 C 2.082031 -4.871094 1.898438 -4.242188 1.898438 -3.421875 Z "/> +</symbol> +<symbol overflow="visible" id="glyph3-12"> +<path style="stroke:none;" d="M 0.863281 -7.992188 L 0.863281 -9.304688 L 2.007812 -9.304688 L 2.007812 -7.992188 Z M 0.863281 0 L 0.863281 -6.742188 L 2.007812 -6.742188 L 2.007812 0 Z "/> +</symbol> +<symbol overflow="visible" id="glyph3-13"> +<path style="stroke:none;" d="M 5.230469 0 L 5.230469 -0.851562 C 4.804688 -0.183594 4.175781 0.152344 3.34375 0.152344 C 2.808594 0.152344 2.3125 0.00390625 1.863281 -0.292969 C 1.414062 -0.589844 1.0625 -1 0.816406 -1.53125 C 0.570312 -2.0625 0.445312 -2.675781 0.445312 -3.363281 C 0.445312 -4.035156 0.554688 -4.648438 0.78125 -5.195312 C 1.003906 -5.742188 1.339844 -6.164062 1.789062 -6.457031 C 2.238281 -6.75 2.738281 -6.894531 3.292969 -6.894531 C 3.699219 -6.894531 4.0625 -6.808594 4.378906 -6.636719 C 4.695312 -6.464844 4.957031 -6.242188 5.15625 -5.96875 L 5.15625 -9.304688 L 6.289062 -9.304688 L 6.289062 0 Z M 1.617188 -3.363281 C 1.617188 -2.5 1.800781 -1.855469 2.164062 -1.429688 C 2.527344 -1 2.957031 -0.789062 3.453125 -0.789062 C 3.953125 -0.789062 4.375 -0.992188 4.726562 -1.398438 C 5.074219 -1.808594 5.25 -2.429688 5.25 -3.269531 C 5.25 -4.191406 5.070312 -4.867188 4.714844 -5.300781 C 4.359375 -5.730469 3.921875 -5.949219 3.402344 -5.949219 C 2.894531 -5.949219 2.46875 -5.742188 2.128906 -5.324219 C 1.789062 -4.910156 1.617188 -4.257812 1.617188 -3.363281 Z "/> +</symbol> +<symbol overflow="visible" id="glyph3-14"> +<path style="stroke:none;" d="M 4.84375 0 L 3.699219 0 L 3.699219 -7.28125 C 3.425781 -7.019531 3.066406 -6.757812 2.617188 -6.492188 C 2.171875 -6.230469 1.769531 -6.035156 1.414062 -5.902344 L 1.414062 -7.007812 C 2.054688 -7.308594 2.613281 -7.671875 3.089844 -8.101562 C 3.570312 -8.527344 3.90625 -8.941406 4.105469 -9.34375 L 4.84375 -9.34375 Z "/> +</symbol> +</g> +<clipPath id="clip1"> + <path d="M 89 21 L 91 21 L 91 221 L 89 221 Z "/> +</clipPath> +<clipPath id="clip2"> + <path d="M 201 21 L 203 21 L 203 221 L 201 221 Z "/> +</clipPath> +<clipPath id="clip3"> + <path d="M 313 21 L 315 21 L 315 221 L 313 221 Z "/> +</clipPath> +<clipPath id="clip4"> + <path d="M 33 180 L 355 180 L 355 182 L 33 182 Z "/> +</clipPath> +<clipPath id="clip5"> + <path d="M 33 146 L 355 146 L 355 148 L 33 148 Z "/> +</clipPath> +<clipPath id="clip6"> + <path d="M 33 120 L 355 120 L 355 122 L 33 122 Z "/> +</clipPath> +<clipPath id="clip7"> + <path d="M 33 95 L 355 95 L 355 97 L 33 97 Z "/> +</clipPath> +<clipPath id="clip8"> + <path d="M 33 61 L 355 61 L 355 63 L 33 63 Z "/> +</clipPath> +</defs> +<g id="surface11"> +<g clip-path="url(#clip1)" clip-rule="nonzero"> +<path style="fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:0.5;stroke-dasharray:1,2;stroke-miterlimit:3.25;" d="M 90.226562 220.007812 L 90.226562 21 "/> +</g> +<g clip-path="url(#clip2)" clip-rule="nonzero"> +<path style="fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:0.5;stroke-dasharray:1,2;stroke-miterlimit:3.25;" d="M 201.996094 220.007812 L 201.996094 21 "/> +</g> +<g clip-path="url(#clip3)" clip-rule="nonzero"> +<path style="fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:0.5;stroke-dasharray:1,2;stroke-miterlimit:3.25;" d="M 313.761719 220.007812 L 313.761719 21 "/> +</g> +<g clip-path="url(#clip4)" clip-rule="nonzero"> +<path style="fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:0.5;stroke-dasharray:1,2;stroke-miterlimit:3.25;" d="M 33 180.734375 L 355 180.734375 "/> +</g> +<g clip-path="url(#clip5)" clip-rule="nonzero"> +<path style="fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:0.5;stroke-dasharray:1,2;stroke-miterlimit:3.25;" d="M 33 146.960938 L 355 146.960938 "/> +</g> +<g clip-path="url(#clip6)" clip-rule="nonzero"> +<path style="fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:0.5;stroke-dasharray:1,2;stroke-miterlimit:3.25;" d="M 33 121.410156 L 355 121.410156 "/> +</g> +<g clip-path="url(#clip7)" clip-rule="nonzero"> +<path style="fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:0.5;stroke-dasharray:1,2;stroke-miterlimit:3.25;" d="M 33 95.859375 L 355 95.859375 "/> +</g> +<g clip-path="url(#clip8)" clip-rule="nonzero"> +<path style="fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:0.5;stroke-dasharray:1,2;stroke-miterlimit:3.25;" d="M 33 62.082031 L 355 62.082031 "/> +</g> +<path style=" stroke:none;fill-rule:evenodd;fill:rgb(36.84082%,50.67749%,70.979309%);fill-opacity:1;" d="M 49.128906 169 C 49.128906 168.167969 48.800781 167.375 48.214844 166.785156 C 47.625 166.199219 46.832031 165.871094 46 165.871094 C 45.167969 165.871094 44.375 166.199219 43.785156 166.785156 C 43.199219 167.375 42.871094 168.167969 42.871094 169 C 42.871094 169.832031 43.199219 170.625 43.785156 171.214844 C 44.375 171.800781 45.167969 172.128906 46 172.128906 C 46.832031 172.128906 47.625 171.800781 48.214844 171.214844 C 48.800781 170.625 49.128906 169.832031 49.128906 169 Z "/> +<path style=" stroke:none;fill-rule:evenodd;fill:rgb(36.84082%,50.67749%,70.979309%);fill-opacity:1;" d="M 82.128906 169 C 82.128906 168.167969 81.800781 167.375 81.214844 166.785156 C 80.625 166.199219 79.832031 165.871094 79 165.871094 C 78.167969 165.871094 77.375 166.199219 76.785156 166.785156 C 76.199219 167.375 75.871094 168.167969 75.871094 169 C 75.871094 169.832031 76.199219 170.625 76.785156 171.214844 C 77.375 171.800781 78.167969 172.128906 79 172.128906 C 79.832031 172.128906 80.625 171.800781 81.214844 171.214844 C 81.800781 170.625 82.128906 169.832031 82.128906 169 Z "/> +<path style=" stroke:none;fill-rule:evenodd;fill:rgb(36.84082%,50.67749%,70.979309%);fill-opacity:1;" d="M 116.128906 167 C 116.128906 166.167969 115.800781 165.375 115.214844 164.785156 C 114.625 164.199219 113.832031 163.871094 113 163.871094 C 112.167969 163.871094 111.375 164.199219 110.785156 164.785156 C 110.199219 165.375 109.871094 166.167969 109.871094 167 C 109.871094 167.832031 110.199219 168.625 110.785156 169.214844 C 111.375 169.800781 112.167969 170.128906 113 170.128906 C 113.832031 170.128906 114.625 169.800781 115.214844 169.214844 C 115.800781 168.625 116.128906 167.832031 116.128906 167 Z "/> +<path style=" stroke:none;fill-rule:evenodd;fill:rgb(36.84082%,50.67749%,70.979309%);fill-opacity:1;" d="M 150.128906 159 C 150.128906 158.167969 149.800781 157.375 149.214844 156.785156 C 148.625 156.199219 147.832031 155.871094 147 155.871094 C 146.167969 155.871094 145.375 156.199219 144.785156 156.785156 C 144.199219 157.375 143.871094 158.167969 143.871094 159 C 143.871094 159.832031 144.199219 160.625 144.785156 161.214844 C 145.375 161.800781 146.167969 162.128906 147 162.128906 C 147.832031 162.128906 148.625 161.800781 149.214844 161.214844 C 149.800781 160.625 150.128906 159.832031 150.128906 159 Z "/> +<path style=" stroke:none;fill-rule:evenodd;fill:rgb(36.84082%,50.67749%,70.979309%);fill-opacity:1;" d="M 183.128906 146 C 183.128906 145.167969 182.800781 144.375 182.214844 143.785156 C 181.625 143.199219 180.832031 142.871094 180 142.871094 C 179.167969 142.871094 178.375 143.199219 177.785156 143.785156 C 177.199219 144.375 176.871094 145.167969 176.871094 146 C 176.871094 146.832031 177.199219 147.625 177.785156 148.214844 C 178.375 148.800781 179.167969 149.128906 180 149.128906 C 180.832031 149.128906 181.625 148.800781 182.214844 148.214844 C 182.800781 147.625 183.128906 146.832031 183.128906 146 Z "/> +<path style=" stroke:none;fill-rule:evenodd;fill:rgb(36.84082%,50.67749%,70.979309%);fill-opacity:1;" d="M 217.128906 128 C 217.128906 127.167969 216.800781 126.375 216.214844 125.785156 C 215.625 125.199219 214.832031 124.871094 214 124.871094 C 213.167969 124.871094 212.375 125.199219 211.785156 125.785156 C 211.199219 126.375 210.871094 127.167969 210.871094 128 C 210.871094 128.832031 211.199219 129.625 211.785156 130.214844 C 212.375 130.800781 213.167969 131.128906 214 131.128906 C 214.832031 131.128906 215.625 130.800781 216.214844 130.214844 C 216.800781 129.625 217.128906 128.832031 217.128906 128 Z "/> +<path style=" stroke:none;fill-rule:evenodd;fill:rgb(36.84082%,50.67749%,70.979309%);fill-opacity:1;" d="M 251.128906 108 C 251.128906 107.167969 250.800781 106.375 250.214844 105.785156 C 249.625 105.199219 248.832031 104.871094 248 104.871094 C 247.167969 104.871094 246.375 105.199219 245.785156 105.785156 C 245.199219 106.375 244.871094 107.167969 244.871094 108 C 244.871094 108.832031 245.199219 109.625 245.785156 110.214844 C 246.375 110.800781 247.167969 111.128906 248 111.128906 C 248.832031 111.128906 249.625 110.800781 250.214844 110.214844 C 250.800781 109.625 251.128906 108.832031 251.128906 108 Z "/> +<path style=" stroke:none;fill-rule:evenodd;fill:rgb(36.84082%,50.67749%,70.979309%);fill-opacity:1;" d="M 284.128906 85 C 284.128906 84.167969 283.800781 83.375 283.214844 82.785156 C 282.625 82.199219 281.832031 81.871094 281 81.871094 C 280.167969 81.871094 279.375 82.199219 278.785156 82.785156 C 278.199219 83.375 277.871094 84.167969 277.871094 85 C 277.871094 85.832031 278.199219 86.625 278.785156 87.214844 C 279.375 87.800781 280.167969 88.128906 281 88.128906 C 281.832031 88.128906 282.625 87.800781 283.214844 87.214844 C 283.800781 86.625 284.128906 85.832031 284.128906 85 Z "/> +<path style=" stroke:none;fill-rule:evenodd;fill:rgb(36.84082%,50.67749%,70.979309%);fill-opacity:1;" d="M 318.128906 59 C 318.128906 58.167969 317.800781 57.375 317.214844 56.785156 C 316.625 56.199219 315.832031 55.871094 315 55.871094 C 314.167969 55.871094 313.375 56.199219 312.785156 56.785156 C 312.199219 57.375 311.871094 58.167969 311.871094 59 C 311.871094 59.832031 312.199219 60.625 312.785156 61.214844 C 313.375 61.800781 314.167969 62.128906 315 62.128906 C 315.832031 62.128906 316.625 61.800781 317.214844 61.214844 C 317.800781 60.625 318.128906 59.832031 318.128906 59 Z "/> +<path style=" stroke:none;fill-rule:evenodd;fill:rgb(36.84082%,50.67749%,70.979309%);fill-opacity:1;" d="M 352.128906 31 C 352.128906 30.167969 351.800781 29.375 351.214844 28.785156 C 350.625 28.199219 349.832031 27.871094 349 27.871094 C 348.167969 27.871094 347.375 28.199219 346.785156 28.785156 C 346.199219 29.375 345.871094 30.167969 345.871094 31 C 345.871094 31.832031 346.199219 32.625 346.785156 33.214844 C 347.375 33.800781 348.167969 34.128906 349 34.128906 C 349.832031 34.128906 350.625 33.800781 351.214844 33.214844 C 351.800781 32.625 352.128906 31.832031 352.128906 31 Z "/> +<path style=" stroke:none;fill-rule:evenodd;fill:rgb(88.070679%,61.103821%,14.204407%);fill-opacity:1;" d="M 49.128906 205 C 49.128906 204.167969 48.800781 203.375 48.214844 202.785156 C 47.625 202.199219 46.832031 201.871094 46 201.871094 C 45.167969 201.871094 44.375 202.199219 43.785156 202.785156 C 43.199219 203.375 42.871094 204.167969 42.871094 205 C 42.871094 205.832031 43.199219 206.625 43.785156 207.214844 C 44.375 207.800781 45.167969 208.128906 46 208.128906 C 46.832031 208.128906 47.625 207.800781 48.214844 207.214844 C 48.800781 206.625 49.128906 205.832031 49.128906 205 Z "/> +<path style=" stroke:none;fill-rule:evenodd;fill:rgb(88.070679%,61.103821%,14.204407%);fill-opacity:1;" d="M 82.128906 199 C 82.128906 198.167969 81.800781 197.375 81.214844 196.785156 C 80.625 196.199219 79.832031 195.871094 79 195.871094 C 78.167969 195.871094 77.375 196.199219 76.785156 196.785156 C 76.199219 197.375 75.871094 198.167969 75.871094 199 C 75.871094 199.832031 76.199219 200.625 76.785156 201.214844 C 77.375 201.800781 78.167969 202.128906 79 202.128906 C 79.832031 202.128906 80.625 201.800781 81.214844 201.214844 C 81.800781 200.625 82.128906 199.832031 82.128906 199 Z "/> +<path style=" stroke:none;fill-rule:evenodd;fill:rgb(88.070679%,61.103821%,14.204407%);fill-opacity:1;" d="M 116.128906 190 C 116.128906 189.167969 115.800781 188.375 115.214844 187.785156 C 114.625 187.199219 113.832031 186.871094 113 186.871094 C 112.167969 186.871094 111.375 187.199219 110.785156 187.785156 C 110.199219 188.375 109.871094 189.167969 109.871094 190 C 109.871094 190.832031 110.199219 191.625 110.785156 192.214844 C 111.375 192.800781 112.167969 193.128906 113 193.128906 C 113.832031 193.128906 114.625 192.800781 115.214844 192.214844 C 115.800781 191.625 116.128906 190.832031 116.128906 190 Z "/> +<path style=" stroke:none;fill-rule:evenodd;fill:rgb(88.070679%,61.103821%,14.204407%);fill-opacity:1;" d="M 150.128906 177 C 150.128906 176.167969 149.800781 175.375 149.214844 174.785156 C 148.625 174.199219 147.832031 173.871094 147 173.871094 C 146.167969 173.871094 145.375 174.199219 144.785156 174.785156 C 144.199219 175.375 143.871094 176.167969 143.871094 177 C 143.871094 177.832031 144.199219 178.625 144.785156 179.214844 C 145.375 179.800781 146.167969 180.128906 147 180.128906 C 147.832031 180.128906 148.625 179.800781 149.214844 179.214844 C 149.800781 178.625 150.128906 177.832031 150.128906 177 Z "/> +<path style=" stroke:none;fill-rule:evenodd;fill:rgb(88.070679%,61.103821%,14.204407%);fill-opacity:1;" d="M 183.128906 159 C 183.128906 158.167969 182.800781 157.375 182.214844 156.785156 C 181.625 156.199219 180.832031 155.871094 180 155.871094 C 179.167969 155.871094 178.375 156.199219 177.785156 156.785156 C 177.199219 157.375 176.871094 158.167969 176.871094 159 C 176.871094 159.832031 177.199219 160.625 177.785156 161.214844 C 178.375 161.800781 179.167969 162.128906 180 162.128906 C 180.832031 162.128906 181.625 161.800781 182.214844 161.214844 C 182.800781 160.625 183.128906 159.832031 183.128906 159 Z "/> +<path style=" stroke:none;fill-rule:evenodd;fill:rgb(88.070679%,61.103821%,14.204407%);fill-opacity:1;" d="M 217.128906 138 C 217.128906 137.167969 216.800781 136.375 216.214844 135.785156 C 215.625 135.199219 214.832031 134.871094 214 134.871094 C 213.167969 134.871094 212.375 135.199219 211.785156 135.785156 C 211.199219 136.375 210.871094 137.167969 210.871094 138 C 210.871094 138.832031 211.199219 139.625 211.785156 140.214844 C 212.375 140.800781 213.167969 141.128906 214 141.128906 C 214.832031 141.128906 215.625 140.800781 216.214844 140.214844 C 216.800781 139.625 217.128906 138.832031 217.128906 138 Z "/> +<path style=" stroke:none;fill-rule:evenodd;fill:rgb(88.070679%,61.103821%,14.204407%);fill-opacity:1;" d="M 251.128906 115 C 251.128906 114.167969 250.800781 113.375 250.214844 112.785156 C 249.625 112.199219 248.832031 111.871094 248 111.871094 C 247.167969 111.871094 246.375 112.199219 245.785156 112.785156 C 245.199219 113.375 244.871094 114.167969 244.871094 115 C 244.871094 115.832031 245.199219 116.625 245.785156 117.214844 C 246.375 117.800781 247.167969 118.128906 248 118.128906 C 248.832031 118.128906 249.625 117.800781 250.214844 117.214844 C 250.800781 116.625 251.128906 115.832031 251.128906 115 Z "/> +<path style=" stroke:none;fill-rule:evenodd;fill:rgb(88.070679%,61.103821%,14.204407%);fill-opacity:1;" d="M 284.128906 91 C 284.128906 90.167969 283.800781 89.375 283.214844 88.785156 C 282.625 88.199219 281.832031 87.871094 281 87.871094 C 280.167969 87.871094 279.375 88.199219 278.785156 88.785156 C 278.199219 89.375 277.871094 90.167969 277.871094 91 C 277.871094 91.832031 278.199219 92.625 278.785156 93.214844 C 279.375 93.800781 280.167969 94.128906 281 94.128906 C 281.832031 94.128906 282.625 93.800781 283.214844 93.214844 C 283.800781 92.625 284.128906 91.832031 284.128906 91 Z "/> +<path style=" stroke:none;fill-rule:evenodd;fill:rgb(88.070679%,61.103821%,14.204407%);fill-opacity:1;" d="M 318.128906 65 C 318.128906 64.167969 317.800781 63.375 317.214844 62.785156 C 316.625 62.199219 315.832031 61.871094 315 61.871094 C 314.167969 61.871094 313.375 62.199219 312.785156 62.785156 C 312.199219 63.375 311.871094 64.167969 311.871094 65 C 311.871094 65.832031 312.199219 66.625 312.785156 67.214844 C 313.375 67.800781 314.167969 68.128906 315 68.128906 C 315.832031 68.128906 316.625 67.800781 317.214844 67.214844 C 317.800781 66.625 318.128906 65.832031 318.128906 65 Z "/> +<path style=" stroke:none;fill-rule:evenodd;fill:rgb(88.070679%,61.103821%,14.204407%);fill-opacity:1;" d="M 352.128906 38 C 352.128906 37.167969 351.800781 36.375 351.214844 35.785156 C 350.625 35.199219 349.832031 34.871094 349 34.871094 C 348.167969 34.871094 347.375 35.199219 346.785156 35.785156 C 346.199219 36.375 345.871094 37.167969 345.871094 38 C 345.871094 38.832031 346.199219 39.625 346.785156 40.214844 C 347.375 40.800781 348.167969 41.128906 349 41.128906 C 349.832031 41.128906 350.625 40.800781 351.214844 40.214844 C 351.800781 39.625 352.128906 38.832031 352.128906 38 Z "/> +<path style="fill:none;stroke-width:0.5;stroke-linecap:square;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 220.007812 L 33 220.007812 "/> +<path style="fill:none;stroke-width:0.5;stroke-linecap:square;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 33 220.007812 L 33 21 "/> +<path style="fill:none;stroke-width:0.5;stroke-linecap:square;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 33 21 L 355 21 "/> +<path style="fill:none;stroke-width:0.5;stroke-linecap:square;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 21 L 355 220.007812 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 90.226562 220.007812 L 90.226562 216.785156 "/> +<g style="fill:rgb(39.99939%,39.99939%,39.99939%);fill-opacity:1;"> + <use xlink:href="#glyph0-1" x="84.725786" y="232.006944"/> + <use xlink:href="#glyph0-2" x="90.28731" y="232.006944"/> +</g> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 201.996094 220.007812 L 201.996094 216.785156 "/> +<g style="fill:rgb(39.99939%,39.99939%,39.99939%);fill-opacity:1;"> + <use xlink:href="#glyph0-1" x="193.49443" y="232.006944"/> + <use xlink:href="#glyph0-2" x="199.055953" y="232.006944"/> + <use xlink:href="#glyph0-2" x="204.617477" y="232.006944"/> +</g> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 313.761719 220.007812 L 313.761719 216.785156 "/> +<g style="fill:rgb(39.99939%,39.99939%,39.99939%);fill-opacity:1;"> + <use xlink:href="#glyph0-1" x="302.763074" y="232.006944"/> + <use xlink:href="#glyph0-2" x="308.324597" y="232.006944"/> + <use xlink:href="#glyph0-2" x="313.88612" y="232.006944"/> + <use xlink:href="#glyph0-2" x="319.447644" y="232.006944"/> +</g> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 45.75 220.007812 L 45.75 218.398438 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 56.578125 220.007812 L 56.578125 218.398438 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 65.429688 220.007812 L 65.429688 218.398438 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 72.914062 220.007812 L 72.914062 218.398438 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 79.394531 220.007812 L 79.394531 218.398438 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 85.113281 220.007812 L 85.113281 218.398438 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 123.871094 220.007812 L 123.871094 218.398438 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 143.554688 220.007812 L 143.554688 218.398438 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 157.515625 220.007812 L 157.515625 218.398438 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 168.347656 220.007812 L 168.347656 218.398438 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 177.199219 220.007812 L 177.199219 218.398438 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 184.679688 220.007812 L 184.679688 218.398438 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 191.164062 220.007812 L 191.164062 218.398438 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 196.878906 220.007812 L 196.878906 218.398438 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 235.640625 220.007812 L 235.640625 218.398438 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 255.320312 220.007812 L 255.320312 218.398438 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 269.285156 220.007812 L 269.285156 218.398438 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 280.117188 220.007812 L 280.117188 218.398438 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 288.96875 220.007812 L 288.96875 218.398438 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 296.449219 220.007812 L 296.449219 218.398438 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 302.929688 220.007812 L 302.929688 218.398438 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 308.648438 220.007812 L 308.648438 218.398438 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 347.410156 220.007812 L 347.410156 218.398438 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 33 180.734375 L 36.21875 180.734375 "/> +<g style="fill:rgb(39.99939%,39.99939%,39.99939%);fill-opacity:1;"> + <use xlink:href="#glyph0-3" x="24" y="183.235493"/> +</g> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 33 146.960938 L 36.21875 146.960938 "/> +<g style="fill:rgb(39.99939%,39.99939%,39.99939%);fill-opacity:1;"> + <use xlink:href="#glyph0-4" x="24" y="149.45964"/> +</g> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 33 121.410156 L 36.21875 121.410156 "/> +<g style="fill:rgb(39.99939%,39.99939%,39.99939%);fill-opacity:1;"> + <use xlink:href="#glyph0-1" x="19" y="123.909193"/> + <use xlink:href="#glyph0-2" x="24.561523" y="123.909193"/> +</g> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 33 95.859375 L 36.21875 95.859375 "/> +<g style="fill:rgb(39.99939%,39.99939%,39.99939%);fill-opacity:1;"> + <use xlink:href="#glyph0-3" x="19" y="98.358747"/> + <use xlink:href="#glyph0-2" x="24.561523" y="98.358747"/> +</g> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 33 62.082031 L 36.21875 62.082031 "/> +<g style="fill:rgb(39.99939%,39.99939%,39.99939%);fill-opacity:1;"> + <use xlink:href="#glyph0-4" x="19" y="64.582894"/> + <use xlink:href="#glyph0-2" x="24.561523" y="64.582894"/> +</g> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 33 206.285156 L 34.609375 206.285156 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 33 165.789062 L 34.609375 165.789062 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 33 155.183594 L 34.609375 155.183594 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 33 140.238281 L 34.609375 140.238281 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 33 134.558594 L 34.609375 134.558594 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 33 129.632812 L 34.609375 129.632812 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 33 125.292969 L 34.609375 125.292969 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 33 80.914062 L 34.609375 80.914062 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 33 70.308594 L 34.609375 70.308594 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 33 36.53125 L 34.609375 36.53125 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 90.226562 21 L 90.226562 24.21875 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 201.996094 21 L 201.996094 24.21875 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 313.761719 21 L 313.761719 24.21875 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 45.75 21 L 45.75 22.609375 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 56.578125 21 L 56.578125 22.609375 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 65.429688 21 L 65.429688 22.609375 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 72.914062 21 L 72.914062 22.609375 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 79.394531 21 L 79.394531 22.609375 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 85.113281 21 L 85.113281 22.609375 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 123.871094 21 L 123.871094 22.609375 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 143.554688 21 L 143.554688 22.609375 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 157.515625 21 L 157.515625 22.609375 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 168.347656 21 L 168.347656 22.609375 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 177.199219 21 L 177.199219 22.609375 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 184.679688 21 L 184.679688 22.609375 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 191.164062 21 L 191.164062 22.609375 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 196.878906 21 L 196.878906 22.609375 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 235.640625 21 L 235.640625 22.609375 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 255.320312 21 L 255.320312 22.609375 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 269.285156 21 L 269.285156 22.609375 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 280.117188 21 L 280.117188 22.609375 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 288.96875 21 L 288.96875 22.609375 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 296.449219 21 L 296.449219 22.609375 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 302.929688 21 L 302.929688 22.609375 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 308.648438 21 L 308.648438 22.609375 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 347.410156 21 L 347.410156 22.609375 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 180.734375 L 351.78125 180.734375 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 146.960938 L 351.78125 146.960938 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 121.410156 L 351.78125 121.410156 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 95.859375 L 351.78125 95.859375 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 62.082031 L 351.78125 62.082031 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 206.285156 L 353.390625 206.285156 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 165.789062 L 353.390625 165.789062 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 155.183594 L 353.390625 155.183594 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 140.238281 L 353.390625 140.238281 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 134.558594 L 353.390625 134.558594 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 129.632812 L 353.390625 129.632812 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 125.292969 L 353.390625 125.292969 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 80.914062 L 353.390625 80.914062 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 70.308594 L 353.390625 70.308594 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 36.53125 L 353.390625 36.53125 "/> +<g style="fill:rgb(39.99939%,39.99939%,39.99939%);fill-opacity:1;"> + <use xlink:href="#glyph0-5" x="172.5" y="251.006944"/> + <use xlink:href="#glyph0-6" x="178.608398" y="251.006944"/> + <use xlink:href="#glyph0-7" x="184.169922" y="251.006944"/> + <use xlink:href="#glyph0-8" x="189.731445" y="251.006944"/> + <use xlink:href="#glyph0-9" x="194.731445" y="251.006944"/> + <use xlink:href="#glyph0-10" x="197.509766" y="251.006944"/> + <use xlink:href="#glyph0-11" x="199.731445" y="251.006944"/> + <use xlink:href="#glyph0-7" x="205.292969" y="251.006944"/> + <use xlink:href="#glyph0-12" x="210.854492" y="251.006944"/> +</g> +<g style="fill:rgb(39.99939%,39.99939%,39.99939%);fill-opacity:1;"> + <use xlink:href="#glyph1-1" x="9" y="140.003472"/> + <use xlink:href="#glyph1-2" x="9" y="133.33355"/> + <use xlink:href="#glyph1-3" x="9" y="127.772027"/> + <use xlink:href="#glyph1-4" x="9" y="122.772027"/> + <use xlink:href="#glyph1-5" x="9" y="117.210503"/> + <use xlink:href="#glyph1-6" x="9" y="111.64898"/> + <use xlink:href="#glyph1-7" x="9" y="106.087457"/> +</g> +<g style="fill:rgb(39.99939%,39.99939%,39.99939%);fill-opacity:1;"> + <use xlink:href="#glyph2-1" x="122" y="12"/> + <use xlink:href="#glyph2-2" x="130.666016" y="12"/> + <use xlink:href="#glyph2-3" x="137.339844" y="12"/> + <use xlink:href="#glyph2-4" x="147.335938" y="12"/> + <use xlink:href="#glyph2-5" x="154.009766" y="12"/> + <use xlink:href="#glyph2-6" x="156.675781" y="12"/> + <use xlink:href="#glyph2-7" x="159.341797" y="12"/> + <use xlink:href="#glyph2-8" x="166.015625" y="12"/> + <use xlink:href="#glyph2-5" x="169.349609" y="12"/> + <use xlink:href="#glyph2-2" x="172.015625" y="12"/> + <use xlink:href="#glyph2-9" x="178.689453" y="12"/> +</g> +<g style="fill:rgb(39.99939%,39.99939%,39.99939%);fill-opacity:1;"> + <use xlink:href="#glyph2-8" x="188" y="12"/> + <use xlink:href="#glyph2-5" x="191.333984" y="12"/> + <use xlink:href="#glyph2-3" x="194" y="12"/> + <use xlink:href="#glyph2-10" x="203.996094" y="12"/> +</g> +<g style="fill:rgb(39.99939%,39.99939%,39.99939%);fill-opacity:1;"> + <use xlink:href="#glyph2-2" x="214" y="12"/> + <use xlink:href="#glyph2-11" x="220.673828" y="12"/> +</g> +<g style="fill:rgb(39.99939%,39.99939%,39.99939%);fill-opacity:1;"> + <use xlink:href="#glyph2-3" x="227" y="12"/> + <use xlink:href="#glyph2-2" x="236.996094" y="12"/> + <use xlink:href="#glyph2-12" x="243.669922" y="12"/> + <use xlink:href="#glyph2-13" x="250.34375" y="12"/> + <use xlink:href="#glyph2-6" x="257.017578" y="12"/> + <use xlink:href="#glyph2-10" x="259.683594" y="12"/> +</g> +<path style=" stroke:none;fill-rule:evenodd;fill:rgb(36.84082%,50.67749%,70.979309%);fill-opacity:1;" d="M 382.148438 116 C 382.148438 115.164062 381.816406 114.363281 381.226562 113.773438 C 380.636719 113.183594 379.835938 112.851562 379 112.851562 C 378.164062 112.851562 377.363281 113.183594 376.773438 113.773438 C 376.183594 114.363281 375.851562 115.164062 375.851562 116 C 375.851562 116.835938 376.183594 117.636719 376.773438 118.226562 C 377.363281 118.816406 378.164062 119.148438 379 119.148438 C 379.835938 119.148438 380.636719 118.816406 381.226562 118.226562 C 381.816406 117.636719 382.148438 116.835938 382.148438 116 Z "/> +<g style="fill:rgb(0%,0%,0%);fill-opacity:1;"> + <use xlink:href="#glyph3-1" x="391" y="120.28418"/> + <use xlink:href="#glyph3-2" x="399.670898" y="120.28418"/> + <use xlink:href="#glyph3-2" x="406.901367" y="120.28418"/> + <use xlink:href="#glyph3-3" x="414.131836" y="120.28418"/> + <use xlink:href="#glyph3-4" x="420.631836" y="120.28418"/> +</g> +<g style="fill:rgb(0%,0%,0%);fill-opacity:1;"> + <use xlink:href="#glyph3-5" x="424" y="120.28418"/> +</g> +<g style="fill:rgb(0%,0%,0%);fill-opacity:1;"> + <use xlink:href="#glyph3-6" x="428" y="120.28418"/> + <use xlink:href="#glyph3-7" x="436.670898" y="120.28418"/> + <use xlink:href="#glyph3-4" x="443.170898" y="120.28418"/> + <use xlink:href="#glyph3-8" x="446.783203" y="120.28418"/> + <use xlink:href="#glyph3-2" x="454.013672" y="120.28418"/> + <use xlink:href="#glyph3-9" x="461.244141" y="120.28418"/> +</g> +<path style=" stroke:none;fill-rule:evenodd;fill:rgb(88.070679%,61.103821%,14.204407%);fill-opacity:1;" d="M 382.148438 139 C 382.148438 138.164062 381.816406 137.363281 381.226562 136.773438 C 380.636719 136.183594 379.835938 135.851562 379 135.851562 C 378.164062 135.851562 377.363281 136.183594 376.773438 136.773438 C 376.183594 137.363281 375.851562 138.164062 375.851562 139 C 375.851562 139.835938 376.183594 140.636719 376.773438 141.226562 C 377.363281 141.816406 378.164062 142.148438 379 142.148438 C 379.835938 142.148438 380.636719 141.816406 381.226562 141.226562 C 381.816406 140.636719 382.148438 139.835938 382.148438 139 Z "/> +<g style="fill:rgb(0%,0%,0%);fill-opacity:1;"> + <use xlink:href="#glyph3-10" x="391" y="143.28418"/> + <use xlink:href="#glyph3-7" x="398.230469" y="143.28418"/> + <use xlink:href="#glyph3-11" x="404.730469" y="143.28418"/> + <use xlink:href="#glyph3-12" x="411.960938" y="143.28418"/> + <use xlink:href="#glyph3-9" x="414.849609" y="143.28418"/> + <use xlink:href="#glyph3-13" x="422.080078" y="143.28418"/> + <use xlink:href="#glyph3-14" x="429.310547" y="143.28418"/> + <use xlink:href="#glyph3-14" x="436.541016" y="143.28418"/> +</g> +</g> +</svg> diff --git a/stormpy/resources/pybind11/docs/pybind11_vs_boost_python2.svg b/stormpy/resources/pybind11/docs/pybind11_vs_boost_python2.svg new file mode 100644 index 000000000..5ed6530ca --- /dev/null +++ b/stormpy/resources/pybind11/docs/pybind11_vs_boost_python2.svg @@ -0,0 +1,427 @@ +<?xml version="1.0" encoding="UTF-8"?> +<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="468pt" height="246pt" viewBox="0 0 468 246" version="1.1"> +<defs> +<g> +<symbol overflow="visible" id="glyph0-0"> +<path style="stroke:none;" d=""/> +</symbol> +<symbol overflow="visible" id="glyph0-1"> +<path style="stroke:none;" d="M 3.726562 0 L 2.847656 0 L 2.847656 -5.601562 C 2.636719 -5.398438 2.359375 -5.195312 2.015625 -4.996094 C 1.671875 -4.792969 1.363281 -4.640625 1.089844 -4.539062 L 1.089844 -5.390625 C 1.582031 -5.621094 2.011719 -5.902344 2.378906 -6.230469 C 2.746094 -6.558594 3.007812 -6.878906 3.160156 -7.1875 L 3.726562 -7.1875 Z "/> +</symbol> +<symbol overflow="visible" id="glyph0-2"> +<path style="stroke:none;" d="M 0.414062 -3.53125 C 0.414062 -4.375 0.503906 -5.058594 0.675781 -5.574219 C 0.851562 -6.089844 1.109375 -6.488281 1.453125 -6.765625 C 1.796875 -7.046875 2.226562 -7.1875 2.75 -7.1875 C 3.132812 -7.1875 3.46875 -7.109375 3.757812 -6.957031 C 4.046875 -6.800781 4.289062 -6.578125 4.476562 -6.285156 C 4.664062 -5.996094 4.8125 -5.640625 4.921875 -5.222656 C 5.03125 -4.804688 5.082031 -4.238281 5.082031 -3.53125 C 5.082031 -2.691406 4.996094 -2.011719 4.824219 -1.496094 C 4.652344 -0.980469 4.394531 -0.582031 4.050781 -0.300781 C 3.707031 -0.0195312 3.273438 0.121094 2.75 0.121094 C 2.058594 0.121094 1.515625 -0.125 1.125 -0.621094 C 0.652344 -1.214844 0.414062 -2.1875 0.414062 -3.53125 Z M 1.320312 -3.53125 C 1.320312 -2.355469 1.457031 -1.574219 1.730469 -1.183594 C 2.007812 -0.796875 2.34375 -0.601562 2.75 -0.601562 C 3.152344 -0.601562 3.492188 -0.796875 3.765625 -1.1875 C 4.042969 -1.578125 4.179688 -2.359375 4.179688 -3.53125 C 4.179688 -4.710938 4.042969 -5.492188 3.765625 -5.878906 C 3.492188 -6.265625 3.148438 -6.460938 2.738281 -6.460938 C 2.335938 -6.460938 2.011719 -6.289062 1.773438 -5.945312 C 1.46875 -5.511719 1.320312 -4.707031 1.320312 -3.53125 Z "/> +</symbol> +<symbol overflow="visible" id="glyph0-3"> +<path style="stroke:none;" d="M 0.820312 0 L 0.820312 -7.15625 L 5.648438 -7.15625 L 5.648438 -6.3125 L 1.765625 -6.3125 L 1.765625 -4.097656 L 5.125 -4.097656 L 5.125 -3.25 L 1.765625 -3.25 L 1.765625 0 Z "/> +</symbol> +<symbol overflow="visible" id="glyph0-4"> +<path style="stroke:none;" d="M 4.058594 0 L 4.058594 -0.761719 C 3.65625 -0.175781 3.105469 0.117188 2.414062 0.117188 C 2.105469 0.117188 1.820312 0.0585938 1.554688 -0.0585938 C 1.289062 -0.175781 1.09375 -0.324219 0.964844 -0.5 C 0.835938 -0.679688 0.746094 -0.894531 0.695312 -1.152344 C 0.65625 -1.324219 0.640625 -1.597656 0.640625 -1.972656 L 0.640625 -5.1875 L 1.519531 -5.1875 L 1.519531 -2.308594 C 1.519531 -1.851562 1.535156 -1.542969 1.570312 -1.382812 C 1.625 -1.152344 1.746094 -0.96875 1.921875 -0.835938 C 2.101562 -0.703125 2.324219 -0.640625 2.585938 -0.640625 C 2.851562 -0.640625 3.097656 -0.707031 3.328125 -0.84375 C 3.5625 -0.976562 3.726562 -1.160156 3.820312 -1.394531 C 3.917969 -1.625 3.964844 -1.964844 3.964844 -2.40625 L 3.964844 -5.1875 L 4.84375 -5.1875 L 4.84375 0 Z "/> +</symbol> +<symbol overflow="visible" id="glyph0-5"> +<path style="stroke:none;" d="M 0.660156 0 L 0.660156 -5.1875 L 1.449219 -5.1875 L 1.449219 -4.449219 C 1.832031 -5.019531 2.382812 -5.304688 3.101562 -5.304688 C 3.414062 -5.304688 3.699219 -5.246094 3.960938 -5.132812 C 4.222656 -5.023438 4.421875 -4.875 4.550781 -4.691406 C 4.679688 -4.507812 4.773438 -4.292969 4.824219 -4.042969 C 4.855469 -3.878906 4.875 -3.59375 4.875 -3.1875 L 4.875 0 L 3.992188 0 L 3.992188 -3.15625 C 3.992188 -3.511719 3.960938 -3.78125 3.890625 -3.957031 C 3.824219 -4.132812 3.703125 -4.277344 3.527344 -4.382812 C 3.351562 -4.488281 3.148438 -4.539062 2.914062 -4.539062 C 2.539062 -4.539062 2.21875 -4.421875 1.945312 -4.183594 C 1.671875 -3.945312 1.539062 -3.496094 1.539062 -2.832031 L 1.539062 0 Z "/> +</symbol> +<symbol overflow="visible" id="glyph0-6"> +<path style="stroke:none;" d="M 4.042969 -1.898438 L 4.90625 -1.789062 C 4.8125 -1.191406 4.570312 -0.726562 4.183594 -0.386719 C 3.792969 -0.0507812 3.316406 0.117188 2.75 0.117188 C 2.039062 0.117188 1.46875 -0.113281 1.039062 -0.578125 C 0.605469 -1.042969 0.390625 -1.707031 0.390625 -2.574219 C 0.390625 -3.132812 0.484375 -3.625 0.667969 -4.042969 C 0.855469 -4.460938 1.136719 -4.777344 1.515625 -4.988281 C 1.894531 -5.199219 2.308594 -5.304688 2.753906 -5.304688 C 3.316406 -5.304688 3.777344 -5.160156 4.136719 -4.875 C 4.492188 -4.589844 4.722656 -4.1875 4.824219 -3.664062 L 3.96875 -3.53125 C 3.886719 -3.878906 3.746094 -4.140625 3.539062 -4.316406 C 3.332031 -4.492188 3.082031 -4.578125 2.789062 -4.578125 C 2.34375 -4.578125 1.984375 -4.421875 1.710938 -4.105469 C 1.433594 -3.789062 1.292969 -3.285156 1.292969 -2.597656 C 1.292969 -1.902344 1.425781 -1.394531 1.695312 -1.078125 C 1.960938 -0.761719 2.308594 -0.605469 2.738281 -0.605469 C 3.085938 -0.605469 3.371094 -0.710938 3.601562 -0.921875 C 3.835938 -1.132812 3.980469 -1.460938 4.042969 -1.898438 Z "/> +</symbol> +<symbol overflow="visible" id="glyph0-7"> +<path style="stroke:none;" d="M 2.578125 -0.785156 L 2.703125 -0.0078125 C 2.457031 0.0429688 2.234375 0.0703125 2.039062 0.0703125 C 1.722656 0.0703125 1.476562 0.0195312 1.296875 -0.0820312 C 1.121094 -0.183594 1 -0.316406 0.929688 -0.480469 C 0.855469 -0.644531 0.820312 -0.992188 0.820312 -1.519531 L 0.820312 -4.5 L 0.175781 -4.5 L 0.175781 -5.1875 L 0.820312 -5.1875 L 0.820312 -6.46875 L 1.695312 -6.996094 L 1.695312 -5.1875 L 2.578125 -5.1875 L 2.578125 -4.5 L 1.695312 -4.5 L 1.695312 -1.46875 C 1.695312 -1.21875 1.710938 -1.058594 1.742188 -0.984375 C 1.773438 -0.914062 1.820312 -0.859375 1.890625 -0.816406 C 1.960938 -0.773438 2.0625 -0.75 2.191406 -0.75 C 2.289062 -0.75 2.417969 -0.761719 2.578125 -0.785156 Z "/> +</symbol> +<symbol overflow="visible" id="glyph0-8"> +<path style="stroke:none;" d="M 0.664062 -6.148438 L 0.664062 -7.15625 L 1.542969 -7.15625 L 1.542969 -6.148438 Z M 0.664062 0 L 0.664062 -5.1875 L 1.542969 -5.1875 L 1.542969 0 Z "/> +</symbol> +<symbol overflow="visible" id="glyph0-9"> +<path style="stroke:none;" d="M 0.332031 -2.59375 C 0.332031 -3.554688 0.597656 -4.265625 1.132812 -4.726562 C 1.578125 -5.109375 2.121094 -5.304688 2.765625 -5.304688 C 3.476562 -5.304688 4.058594 -5.070312 4.511719 -4.601562 C 4.964844 -4.132812 5.191406 -3.488281 5.191406 -2.664062 C 5.191406 -2 5.089844 -1.472656 4.890625 -1.089844 C 4.691406 -0.707031 4.398438 -0.410156 4.015625 -0.199219 C 3.632812 0.0117188 3.214844 0.117188 2.765625 0.117188 C 2.039062 0.117188 1.449219 -0.117188 1.003906 -0.582031 C 0.554688 -1.046875 0.332031 -1.71875 0.332031 -2.59375 Z M 1.234375 -2.59375 C 1.234375 -1.929688 1.378906 -1.429688 1.671875 -1.101562 C 1.960938 -0.769531 2.324219 -0.605469 2.765625 -0.605469 C 3.199219 -0.605469 3.5625 -0.773438 3.851562 -1.101562 C 4.140625 -1.433594 4.289062 -1.941406 4.289062 -2.621094 C 4.289062 -3.261719 4.140625 -3.75 3.851562 -4.078125 C 3.558594 -4.410156 3.195312 -4.574219 2.765625 -4.574219 C 2.324219 -4.574219 1.960938 -4.410156 1.671875 -4.082031 C 1.382812 -3.753906 1.234375 -3.257812 1.234375 -2.59375 Z "/> +</symbol> +<symbol overflow="visible" id="glyph0-10"> +<path style="stroke:none;" d="M 0.308594 -1.546875 L 1.175781 -1.683594 C 1.226562 -1.335938 1.363281 -1.070312 1.585938 -0.882812 C 1.808594 -0.699219 2.117188 -0.605469 2.519531 -0.605469 C 2.921875 -0.605469 3.222656 -0.6875 3.417969 -0.851562 C 3.613281 -1.015625 3.710938 -1.210938 3.710938 -1.429688 C 3.710938 -1.628906 3.625 -1.785156 3.453125 -1.898438 C 3.332031 -1.976562 3.03125 -2.078125 2.554688 -2.195312 C 1.910156 -2.359375 1.460938 -2.5 1.214844 -2.621094 C 0.964844 -2.738281 0.777344 -2.902344 0.648438 -3.113281 C 0.519531 -3.324219 0.453125 -3.554688 0.453125 -3.808594 C 0.453125 -4.039062 0.507812 -4.253906 0.613281 -4.449219 C 0.71875 -4.648438 0.863281 -4.8125 1.046875 -4.941406 C 1.183594 -5.042969 1.367188 -5.128906 1.605469 -5.199219 C 1.839844 -5.269531 2.09375 -5.304688 2.363281 -5.304688 C 2.769531 -5.304688 3.128906 -5.242188 3.433594 -5.125 C 3.742188 -5.007812 3.96875 -4.851562 4.117188 -4.652344 C 4.261719 -4.453125 4.363281 -4.183594 4.417969 -3.847656 L 3.558594 -3.730469 C 3.519531 -3.996094 3.40625 -4.207031 3.21875 -4.355469 C 3.03125 -4.503906 2.769531 -4.578125 2.425781 -4.578125 C 2.023438 -4.578125 1.734375 -4.511719 1.5625 -4.378906 C 1.390625 -4.246094 1.304688 -4.089844 1.304688 -3.910156 C 1.304688 -3.796875 1.339844 -3.695312 1.410156 -3.601562 C 1.484375 -3.507812 1.59375 -3.429688 1.75 -3.367188 C 1.835938 -3.335938 2.09375 -3.261719 2.523438 -3.144531 C 3.144531 -2.976562 3.578125 -2.84375 3.824219 -2.738281 C 4.070312 -2.632812 4.265625 -2.476562 4.40625 -2.273438 C 4.546875 -2.074219 4.613281 -1.824219 4.613281 -1.523438 C 4.613281 -1.230469 4.527344 -0.953125 4.359375 -0.695312 C 4.1875 -0.4375 3.941406 -0.238281 3.617188 -0.09375 C 3.296875 0.046875 2.929688 0.117188 2.523438 0.117188 C 1.851562 0.117188 1.335938 -0.0234375 0.984375 -0.304688 C 0.632812 -0.582031 0.40625 -0.996094 0.308594 -1.546875 Z "/> +</symbol> +<symbol overflow="visible" id="glyph1-0"> +<path style="stroke:none;" d=""/> +</symbol> +<symbol overflow="visible" id="glyph1-1"> +<path style="stroke:none;" d="M 0.375 -1.6875 L 1.203125 -1.757812 C 1.265625 -1.351562 1.410156 -1.050781 1.632812 -0.847656 C 1.855469 -0.644531 2.125 -0.539062 2.445312 -0.539062 C 2.824219 -0.539062 3.148438 -0.683594 3.410156 -0.972656 C 3.671875 -1.257812 3.804688 -1.640625 3.804688 -2.113281 C 3.804688 -2.566406 3.679688 -2.921875 3.425781 -3.179688 C 3.171875 -3.441406 2.839844 -3.574219 2.429688 -3.574219 C 2.175781 -3.574219 1.945312 -3.515625 1.742188 -3.398438 C 1.535156 -3.28125 1.375 -3.132812 1.257812 -2.949219 L 0.515625 -3.046875 L 1.136719 -6.355469 L 4.34375 -6.355469 L 4.34375 -5.597656 L 1.769531 -5.597656 L 1.421875 -3.867188 C 1.808594 -4.136719 2.214844 -4.273438 2.640625 -4.273438 C 3.203125 -4.273438 3.679688 -4.078125 4.066406 -3.6875 C 4.453125 -3.296875 4.644531 -2.796875 4.644531 -2.183594 C 4.644531 -1.601562 4.476562 -1.097656 4.136719 -0.671875 C 3.722656 -0.152344 3.15625 0.109375 2.445312 0.109375 C 1.859375 0.109375 1.378906 -0.0546875 1.007812 -0.382812 C 0.636719 -0.710938 0.425781 -1.144531 0.375 -1.6875 Z "/> +</symbol> +<symbol overflow="visible" id="glyph1-2"> +<path style="stroke:none;" d="M 4.476562 -4.863281 L 3.691406 -4.804688 C 3.621094 -5.113281 3.523438 -5.339844 3.390625 -5.480469 C 3.179688 -5.707031 2.914062 -5.820312 2.601562 -5.820312 C 2.351562 -5.820312 2.128906 -5.75 1.9375 -5.609375 C 1.6875 -5.425781 1.492188 -5.160156 1.347656 -4.8125 C 1.203125 -4.464844 1.132812 -3.96875 1.125 -3.320312 C 1.316406 -3.613281 1.546875 -3.828125 1.824219 -3.96875 C 2.097656 -4.109375 2.386719 -4.179688 2.6875 -4.179688 C 3.214844 -4.179688 3.664062 -3.984375 4.035156 -3.597656 C 4.40625 -3.210938 4.59375 -2.707031 4.59375 -2.09375 C 4.59375 -1.6875 4.503906 -1.3125 4.332031 -0.964844 C 4.15625 -0.617188 3.917969 -0.351562 3.613281 -0.167969 C 3.308594 0.015625 2.960938 0.109375 2.574219 0.109375 C 1.914062 0.109375 1.378906 -0.132812 0.960938 -0.617188 C 0.546875 -1.101562 0.339844 -1.902344 0.339844 -3.015625 C 0.339844 -4.261719 0.570312 -5.164062 1.027344 -5.730469 C 1.429688 -6.222656 1.96875 -6.46875 2.648438 -6.46875 C 3.15625 -6.46875 3.570312 -6.328125 3.894531 -6.042969 C 4.21875 -5.757812 4.414062 -5.367188 4.476562 -4.863281 Z M 1.25 -2.085938 C 1.25 -1.8125 1.304688 -1.554688 1.421875 -1.304688 C 1.539062 -1.054688 1.699219 -0.867188 1.90625 -0.734375 C 2.113281 -0.605469 2.332031 -0.539062 2.5625 -0.539062 C 2.894531 -0.539062 3.183594 -0.675781 3.421875 -0.945312 C 3.664062 -1.214844 3.785156 -1.582031 3.785156 -2.042969 C 3.785156 -2.488281 3.664062 -2.839844 3.429688 -3.097656 C 3.191406 -3.351562 2.890625 -3.480469 2.53125 -3.480469 C 2.171875 -3.480469 1.871094 -3.351562 1.621094 -3.097656 C 1.371094 -2.839844 1.25 -2.503906 1.25 -2.085938 Z "/> +</symbol> +<symbol overflow="visible" id="glyph1-3"> +<path style="stroke:none;" d="M 0.425781 -5.597656 L 0.425781 -6.359375 L 4.597656 -6.359375 L 4.597656 -5.742188 C 4.1875 -5.304688 3.78125 -4.726562 3.378906 -4.003906 C 2.976562 -3.28125 2.664062 -2.535156 2.445312 -1.769531 C 2.285156 -1.230469 2.183594 -0.640625 2.140625 0 L 1.328125 0 C 1.335938 -0.507812 1.4375 -1.117188 1.625 -1.835938 C 1.816406 -2.554688 2.089844 -3.246094 2.445312 -3.914062 C 2.800781 -4.578125 3.179688 -5.140625 3.582031 -5.597656 Z "/> +</symbol> +<symbol overflow="visible" id="glyph2-0"> +<path style="stroke:none;" d=""/> +</symbol> +<symbol overflow="visible" id="glyph2-1"> +<path style="stroke:none;" d="M 0 -0.734375 L -7.15625 -0.734375 L -7.15625 -3.417969 C -7.15625 -3.964844 -7.085938 -4.402344 -6.941406 -4.734375 C -6.796875 -5.0625 -6.574219 -5.324219 -6.273438 -5.511719 C -5.972656 -5.699219 -5.65625 -5.789062 -5.328125 -5.789062 C -5.023438 -5.789062 -4.734375 -5.707031 -4.460938 -5.542969 C -4.191406 -5.375 -3.976562 -5.125 -3.808594 -4.789062 C -3.679688 -5.222656 -3.464844 -5.554688 -3.160156 -5.789062 C -2.851562 -6.023438 -2.492188 -6.136719 -2.074219 -6.136719 C -1.738281 -6.136719 -1.429688 -6.066406 -1.140625 -5.925781 C -0.851562 -5.785156 -0.628906 -5.609375 -0.472656 -5.398438 C -0.316406 -5.191406 -0.199219 -4.929688 -0.121094 -4.617188 C -0.0390625 -4.304688 0 -3.917969 0 -3.460938 Z M -4.148438 -1.679688 L -4.148438 -3.226562 C -4.148438 -3.648438 -4.179688 -3.949219 -4.234375 -4.132812 C -4.304688 -4.371094 -4.421875 -4.554688 -4.589844 -4.675781 C -4.757812 -4.796875 -4.964844 -4.859375 -5.214844 -4.859375 C -5.453125 -4.859375 -5.660156 -4.800781 -5.84375 -4.6875 C -6.023438 -4.574219 -6.148438 -4.410156 -6.214844 -4.199219 C -6.28125 -3.988281 -6.3125 -3.625 -6.3125 -3.109375 L -6.3125 -1.679688 Z M -0.84375 -1.679688 L -0.84375 -3.460938 C -0.84375 -3.765625 -0.855469 -3.984375 -0.878906 -4.105469 C -0.917969 -4.324219 -0.984375 -4.507812 -1.074219 -4.652344 C -1.164062 -4.800781 -1.296875 -4.921875 -1.472656 -5.015625 C -1.648438 -5.109375 -1.847656 -5.15625 -2.074219 -5.15625 C -2.34375 -5.15625 -2.574219 -5.085938 -2.769531 -4.953125 C -2.96875 -4.816406 -3.105469 -4.625 -3.1875 -4.382812 C -3.265625 -4.140625 -3.304688 -3.789062 -3.304688 -3.335938 L -3.304688 -1.679688 Z "/> +</symbol> +<symbol overflow="visible" id="glyph2-2"> +<path style="stroke:none;" d="M 1.996094 -0.621094 L 1.171875 -0.523438 C 1.222656 -0.714844 1.25 -0.882812 1.25 -1.023438 C 1.25 -1.21875 1.21875 -1.375 1.152344 -1.492188 C 1.085938 -1.609375 0.996094 -1.707031 0.878906 -1.78125 C 0.789062 -1.835938 0.574219 -1.925781 0.226562 -2.050781 C 0.175781 -2.066406 0.105469 -2.09375 0.0078125 -2.128906 L -5.1875 -0.160156 L -5.1875 -1.109375 L -2.183594 -2.1875 C -1.800781 -2.328125 -1.402344 -2.453125 -0.980469 -2.5625 C -1.382812 -2.664062 -1.777344 -2.785156 -2.164062 -2.925781 L -5.1875 -4.03125 L -5.1875 -4.914062 L 0.0859375 -2.9375 C 0.65625 -2.726562 1.050781 -2.5625 1.265625 -2.445312 C 1.554688 -2.289062 1.765625 -2.109375 1.902344 -1.910156 C 2.039062 -1.707031 2.105469 -1.464844 2.105469 -1.1875 C 2.105469 -1.015625 2.070312 -0.828125 1.996094 -0.621094 Z "/> +</symbol> +<symbol overflow="visible" id="glyph2-3"> +<path style="stroke:none;" d="M -0.785156 -2.578125 L -0.0078125 -2.703125 C 0.0429688 -2.457031 0.0703125 -2.234375 0.0703125 -2.039062 C 0.0703125 -1.722656 0.0195312 -1.476562 -0.0820312 -1.296875 C -0.183594 -1.121094 -0.316406 -1 -0.480469 -0.929688 C -0.644531 -0.855469 -0.992188 -0.820312 -1.519531 -0.820312 L -4.5 -0.820312 L -4.5 -0.175781 L -5.1875 -0.175781 L -5.1875 -0.820312 L -6.46875 -0.820312 L -6.996094 -1.695312 L -5.1875 -1.695312 L -5.1875 -2.578125 L -4.5 -2.578125 L -4.5 -1.695312 L -1.46875 -1.695312 C -1.21875 -1.695312 -1.058594 -1.710938 -0.984375 -1.742188 C -0.914062 -1.773438 -0.859375 -1.820312 -0.816406 -1.890625 C -0.773438 -1.960938 -0.75 -2.0625 -0.75 -2.191406 C -0.75 -2.289062 -0.761719 -2.417969 -0.785156 -2.578125 Z "/> +</symbol> +<symbol overflow="visible" id="glyph2-4"> +<path style="stroke:none;" d="M -1.671875 -4.210938 L -1.558594 -5.117188 C -1.027344 -4.972656 -0.617188 -4.707031 -0.320312 -4.320312 C -0.0273438 -3.933594 0.117188 -3.4375 0.117188 -2.835938 C 0.117188 -2.078125 -0.117188 -1.476562 -0.582031 -1.03125 C -1.050781 -0.585938 -1.707031 -0.367188 -2.546875 -0.367188 C -3.421875 -0.367188 -4.097656 -0.589844 -4.578125 -1.039062 C -5.0625 -1.488281 -5.304688 -2.070312 -5.304688 -2.789062 C -5.304688 -3.480469 -5.066406 -4.046875 -4.59375 -4.488281 C -4.121094 -4.925781 -3.457031 -5.148438 -2.601562 -5.148438 C -2.550781 -5.148438 -2.472656 -5.144531 -2.367188 -5.140625 L -2.367188 -1.273438 C -1.796875 -1.304688 -1.363281 -1.46875 -1.058594 -1.757812 C -0.757812 -2.046875 -0.605469 -2.410156 -0.605469 -2.84375 C -0.605469 -3.164062 -0.691406 -3.4375 -0.859375 -3.667969 C -1.027344 -3.894531 -1.296875 -4.074219 -1.671875 -4.210938 Z M -3.089844 -1.324219 L -3.089844 -4.21875 C -3.527344 -4.179688 -3.855469 -4.070312 -4.070312 -3.886719 C -4.410156 -3.605469 -4.578125 -3.242188 -4.578125 -2.796875 C -4.578125 -2.394531 -4.445312 -2.054688 -4.175781 -1.78125 C -3.90625 -1.503906 -3.542969 -1.351562 -3.089844 -1.324219 Z "/> +</symbol> +<symbol overflow="visible" id="glyph2-5"> +<path style="stroke:none;" d="M -1.546875 -0.308594 L -1.683594 -1.175781 C -1.335938 -1.226562 -1.070312 -1.363281 -0.882812 -1.585938 C -0.699219 -1.808594 -0.605469 -2.117188 -0.605469 -2.519531 C -0.605469 -2.921875 -0.6875 -3.222656 -0.851562 -3.417969 C -1.015625 -3.613281 -1.210938 -3.710938 -1.429688 -3.710938 C -1.628906 -3.710938 -1.785156 -3.625 -1.898438 -3.453125 C -1.976562 -3.332031 -2.078125 -3.03125 -2.195312 -2.554688 C -2.359375 -1.910156 -2.5 -1.460938 -2.621094 -1.214844 C -2.738281 -0.964844 -2.902344 -0.777344 -3.113281 -0.648438 C -3.324219 -0.519531 -3.554688 -0.453125 -3.808594 -0.453125 C -4.039062 -0.453125 -4.253906 -0.507812 -4.449219 -0.613281 C -4.648438 -0.71875 -4.8125 -0.863281 -4.941406 -1.046875 C -5.042969 -1.183594 -5.128906 -1.367188 -5.199219 -1.605469 C -5.269531 -1.839844 -5.304688 -2.09375 -5.304688 -2.363281 C -5.304688 -2.769531 -5.242188 -3.128906 -5.125 -3.433594 C -5.007812 -3.742188 -4.851562 -3.96875 -4.652344 -4.117188 C -4.453125 -4.261719 -4.183594 -4.363281 -3.847656 -4.417969 L -3.730469 -3.558594 C -3.996094 -3.519531 -4.207031 -3.40625 -4.355469 -3.21875 C -4.503906 -3.03125 -4.578125 -2.769531 -4.578125 -2.425781 C -4.578125 -2.023438 -4.511719 -1.734375 -4.378906 -1.5625 C -4.246094 -1.390625 -4.089844 -1.304688 -3.910156 -1.304688 C -3.796875 -1.304688 -3.695312 -1.339844 -3.601562 -1.410156 C -3.507812 -1.484375 -3.429688 -1.59375 -3.367188 -1.75 C -3.335938 -1.835938 -3.261719 -2.09375 -3.144531 -2.523438 C -2.976562 -3.144531 -2.84375 -3.578125 -2.738281 -3.824219 C -2.632812 -4.070312 -2.476562 -4.265625 -2.273438 -4.40625 C -2.074219 -4.546875 -1.824219 -4.613281 -1.523438 -4.613281 C -1.230469 -4.613281 -0.953125 -4.527344 -0.695312 -4.359375 C -0.4375 -4.1875 -0.238281 -3.941406 -0.09375 -3.617188 C 0.046875 -3.296875 0.117188 -2.929688 0.117188 -2.523438 C 0.117188 -1.851562 -0.0234375 -1.335938 -0.304688 -0.984375 C -0.582031 -0.632812 -0.996094 -0.40625 -1.546875 -0.308594 Z "/> +</symbol> +<symbol overflow="visible" id="glyph3-0"> +<path style="stroke:none;" d=""/> +</symbol> +<symbol overflow="visible" id="glyph3-1"> +<path style="stroke:none;" d="M 0.984375 0 L 0.984375 -8.589844 L 6.78125 -8.589844 L 6.78125 -7.578125 L 2.121094 -7.578125 L 2.121094 -4.914062 L 6.152344 -4.914062 L 6.152344 -3.902344 L 2.121094 -3.902344 L 2.121094 0 Z "/> +</symbol> +<symbol overflow="visible" id="glyph3-2"> +<path style="stroke:none;" d="M 0.796875 -7.375 L 0.796875 -8.589844 L 1.851562 -8.589844 L 1.851562 -7.375 Z M 0.796875 0 L 0.796875 -6.222656 L 1.851562 -6.222656 L 1.851562 0 Z "/> +</symbol> +<symbol overflow="visible" id="glyph3-3"> +<path style="stroke:none;" d="M 0.765625 0 L 0.765625 -8.589844 L 1.820312 -8.589844 L 1.820312 0 Z "/> +</symbol> +<symbol overflow="visible" id="glyph3-4"> +<path style="stroke:none;" d="M 5.050781 -2.003906 L 6.140625 -1.867188 C 5.96875 -1.230469 5.648438 -0.738281 5.1875 -0.386719 C 4.722656 -0.0351562 4.125 0.140625 3.40625 0.140625 C 2.496094 0.140625 1.773438 -0.140625 1.238281 -0.699219 C 0.707031 -1.261719 0.4375 -2.046875 0.4375 -3.058594 C 0.4375 -4.105469 0.710938 -4.917969 1.25 -5.496094 C 1.789062 -6.074219 2.484375 -6.363281 3.34375 -6.363281 C 4.175781 -6.363281 4.859375 -6.078125 5.382812 -5.515625 C 5.910156 -4.949219 6.175781 -4.148438 6.175781 -3.125 C 6.175781 -3.0625 6.171875 -2.96875 6.171875 -2.84375 L 1.53125 -2.84375 C 1.570312 -2.160156 1.761719 -1.632812 2.109375 -1.273438 C 2.457031 -0.910156 2.890625 -0.726562 3.410156 -0.726562 C 3.796875 -0.726562 4.125 -0.828125 4.398438 -1.03125 C 4.671875 -1.234375 4.890625 -1.558594 5.050781 -2.003906 Z M 1.585938 -3.710938 L 5.0625 -3.710938 C 5.015625 -4.234375 4.882812 -4.625 4.664062 -4.886719 C 4.328125 -5.292969 3.890625 -5.496094 3.359375 -5.496094 C 2.875 -5.496094 2.464844 -5.335938 2.136719 -5.007812 C 1.804688 -4.683594 1.625 -4.25 1.585938 -3.710938 Z "/> +</symbol> +<symbol overflow="visible" id="glyph3-5"> +<path style="stroke:none;" d="M 0.367188 -1.859375 L 1.414062 -2.023438 C 1.472656 -1.605469 1.632812 -1.28125 1.902344 -1.0625 C 2.167969 -0.839844 2.542969 -0.726562 3.023438 -0.726562 C 3.507812 -0.726562 3.867188 -0.824219 4.101562 -1.023438 C 4.335938 -1.21875 4.453125 -1.453125 4.453125 -1.71875 C 4.453125 -1.957031 4.351562 -2.140625 4.140625 -2.28125 C 3.996094 -2.375 3.640625 -2.492188 3.0625 -2.636719 C 2.289062 -2.832031 1.753906 -3 1.457031 -3.144531 C 1.15625 -3.285156 0.929688 -3.484375 0.777344 -3.734375 C 0.621094 -3.988281 0.546875 -4.265625 0.546875 -4.570312 C 0.546875 -4.847656 0.609375 -5.105469 0.734375 -5.339844 C 0.863281 -5.578125 1.035156 -5.773438 1.253906 -5.929688 C 1.417969 -6.050781 1.640625 -6.152344 1.925781 -6.238281 C 2.207031 -6.320312 2.511719 -6.363281 2.835938 -6.363281 C 3.324219 -6.363281 3.753906 -6.292969 4.121094 -6.152344 C 4.492188 -6.011719 4.765625 -5.820312 4.9375 -5.582031 C 5.113281 -5.339844 5.234375 -5.019531 5.304688 -4.617188 L 4.273438 -4.476562 C 4.226562 -4.796875 4.089844 -5.046875 3.863281 -5.226562 C 3.640625 -5.40625 3.320312 -5.496094 2.914062 -5.496094 C 2.429688 -5.496094 2.082031 -5.414062 1.875 -5.257812 C 1.667969 -5.097656 1.5625 -4.90625 1.5625 -4.695312 C 1.5625 -4.558594 1.609375 -4.433594 1.695312 -4.324219 C 1.78125 -4.210938 1.914062 -4.117188 2.097656 -4.042969 C 2.203125 -4.003906 2.515625 -3.914062 3.03125 -3.773438 C 3.777344 -3.574219 4.296875 -3.410156 4.589844 -3.285156 C 4.886719 -3.15625 5.117188 -2.972656 5.285156 -2.730469 C 5.453125 -2.488281 5.539062 -2.1875 5.539062 -1.828125 C 5.539062 -1.476562 5.433594 -1.144531 5.230469 -0.835938 C 5.023438 -0.523438 4.726562 -0.285156 4.34375 -0.113281 C 3.957031 0.0546875 3.515625 0.140625 3.03125 0.140625 C 2.222656 0.140625 1.605469 -0.0273438 1.179688 -0.363281 C 0.757812 -0.699219 0.484375 -1.195312 0.367188 -1.859375 Z "/> +</symbol> +<symbol overflow="visible" id="glyph3-6"> +<path style="stroke:none;" d="M 0.234375 0 L 0.234375 -0.855469 L 4.195312 -5.402344 C 3.746094 -5.378906 3.351562 -5.367188 3.007812 -5.367188 L 0.46875 -5.367188 L 0.46875 -6.222656 L 5.554688 -6.222656 L 5.554688 -5.523438 L 2.1875 -1.578125 L 1.535156 -0.855469 C 2.007812 -0.890625 2.453125 -0.90625 2.867188 -0.90625 L 5.742188 -0.90625 L 5.742188 0 Z "/> +</symbol> +<symbol overflow="visible" id="glyph3-7"> +<path style="stroke:none;" d="M 0.398438 -3.109375 C 0.398438 -4.261719 0.71875 -5.117188 1.359375 -5.671875 C 1.894531 -6.132812 2.546875 -6.363281 3.316406 -6.363281 C 4.171875 -6.363281 4.871094 -6.082031 5.414062 -5.523438 C 5.957031 -4.960938 6.226562 -4.1875 6.226562 -3.199219 C 6.226562 -2.398438 6.109375 -1.769531 5.867188 -1.308594 C 5.628906 -0.851562 5.277344 -0.492188 4.820312 -0.242188 C 4.359375 0.0117188 3.859375 0.140625 3.316406 0.140625 C 2.445312 0.140625 1.742188 -0.140625 1.203125 -0.695312 C 0.667969 -1.253906 0.398438 -2.0625 0.398438 -3.109375 Z M 1.484375 -3.109375 C 1.484375 -2.3125 1.65625 -1.71875 2.003906 -1.320312 C 2.351562 -0.925781 2.789062 -0.726562 3.316406 -0.726562 C 3.839844 -0.726562 4.273438 -0.925781 4.625 -1.324219 C 4.972656 -1.722656 5.144531 -2.328125 5.144531 -3.148438 C 5.144531 -3.917969 4.96875 -4.5 4.621094 -4.894531 C 4.269531 -5.292969 3.835938 -5.492188 3.316406 -5.492188 C 2.789062 -5.492188 2.351562 -5.292969 2.003906 -4.898438 C 1.65625 -4.503906 1.484375 -3.90625 1.484375 -3.109375 Z "/> +</symbol> +<symbol overflow="visible" id="glyph3-8"> +<path style="stroke:none;" d="M 1.042969 0 L 1.042969 -5.402344 L 0.109375 -5.402344 L 0.109375 -6.222656 L 1.042969 -6.222656 L 1.042969 -6.882812 C 1.042969 -7.300781 1.078125 -7.613281 1.15625 -7.816406 C 1.257812 -8.089844 1.433594 -8.3125 1.691406 -8.480469 C 1.945312 -8.652344 2.304688 -8.734375 2.765625 -8.734375 C 3.0625 -8.734375 3.390625 -8.703125 3.75 -8.632812 L 3.59375 -7.710938 C 3.375 -7.75 3.164062 -7.769531 2.96875 -7.769531 C 2.648438 -7.769531 2.421875 -7.703125 2.289062 -7.5625 C 2.15625 -7.425781 2.09375 -7.171875 2.09375 -6.796875 L 2.09375 -6.222656 L 3.304688 -6.222656 L 3.304688 -5.402344 L 2.09375 -5.402344 L 2.09375 0 Z "/> +</symbol> +<symbol overflow="visible" id="glyph3-9"> +<path style="stroke:none;" d="M 0.789062 0 L 0.789062 -6.222656 L 1.734375 -6.222656 L 1.734375 -5.351562 C 1.929688 -5.65625 2.1875 -5.898438 2.515625 -6.085938 C 2.839844 -6.269531 3.207031 -6.363281 3.621094 -6.363281 C 4.082031 -6.363281 4.460938 -6.265625 4.753906 -6.078125 C 5.050781 -5.886719 5.257812 -5.617188 5.378906 -5.273438 C 5.871094 -6 6.511719 -6.363281 7.300781 -6.363281 C 7.917969 -6.363281 8.390625 -6.191406 8.726562 -5.851562 C 9.058594 -5.507812 9.222656 -4.984375 9.222656 -4.273438 L 9.222656 0 L 8.171875 0 L 8.171875 -3.921875 C 8.171875 -4.34375 8.140625 -4.644531 8.070312 -4.832031 C 8.003906 -5.015625 7.878906 -5.164062 7.699219 -5.28125 C 7.519531 -5.394531 7.308594 -5.449219 7.066406 -5.449219 C 6.628906 -5.449219 6.265625 -5.304688 5.976562 -5.011719 C 5.6875 -4.722656 5.542969 -4.257812 5.542969 -3.617188 L 5.542969 0 L 4.488281 0 L 4.488281 -4.042969 C 4.488281 -4.511719 4.402344 -4.863281 4.230469 -5.097656 C 4.058594 -5.332031 3.777344 -5.449219 3.386719 -5.449219 C 3.089844 -5.449219 2.816406 -5.371094 2.5625 -5.214844 C 2.3125 -5.058594 2.128906 -4.828125 2.015625 -4.53125 C 1.902344 -4.230469 1.84375 -3.796875 1.84375 -3.226562 L 1.84375 0 Z "/> +</symbol> +<symbol overflow="visible" id="glyph3-10"> +<path style="stroke:none;" d="M 4.828125 0 L 4.828125 -0.785156 C 4.433594 -0.167969 3.851562 0.140625 3.085938 0.140625 C 2.589844 0.140625 2.136719 0.00390625 1.71875 -0.269531 C 1.304688 -0.542969 0.980469 -0.925781 0.753906 -1.414062 C 0.523438 -1.90625 0.410156 -2.46875 0.410156 -3.105469 C 0.410156 -3.726562 0.515625 -4.289062 0.71875 -4.796875 C 0.925781 -5.300781 1.238281 -5.6875 1.652344 -5.960938 C 2.066406 -6.230469 2.53125 -6.363281 3.039062 -6.363281 C 3.414062 -6.363281 3.75 -6.285156 4.042969 -6.125 C 4.335938 -5.96875 4.574219 -5.761719 4.757812 -5.507812 L 4.757812 -8.589844 L 5.804688 -8.589844 L 5.804688 0 Z M 1.492188 -3.105469 C 1.492188 -2.308594 1.664062 -1.710938 2 -1.320312 C 2.335938 -0.925781 2.730469 -0.726562 3.1875 -0.726562 C 3.648438 -0.726562 4.039062 -0.914062 4.363281 -1.292969 C 4.683594 -1.667969 4.84375 -2.242188 4.84375 -3.015625 C 4.84375 -3.867188 4.679688 -4.492188 4.351562 -4.890625 C 4.023438 -5.289062 3.621094 -5.492188 3.140625 -5.492188 C 2.671875 -5.492188 2.28125 -5.296875 1.964844 -4.914062 C 1.652344 -4.53125 1.492188 -3.929688 1.492188 -3.105469 Z "/> +</symbol> +<symbol overflow="visible" id="glyph3-11"> +<path style="stroke:none;" d="M 4.867188 0 L 4.867188 -0.914062 C 4.382812 -0.210938 3.726562 0.140625 2.894531 0.140625 C 2.527344 0.140625 2.183594 0.0703125 1.867188 -0.0703125 C 1.546875 -0.210938 1.3125 -0.386719 1.15625 -0.601562 C 1.003906 -0.8125 0.894531 -1.074219 0.832031 -1.382812 C 0.789062 -1.589844 0.765625 -1.917969 0.765625 -2.367188 L 0.765625 -6.222656 L 1.820312 -6.222656 L 1.820312 -2.773438 C 1.820312 -2.222656 1.84375 -1.851562 1.886719 -1.65625 C 1.953125 -1.378906 2.09375 -1.164062 2.308594 -1.003906 C 2.523438 -0.847656 2.789062 -0.765625 3.105469 -0.765625 C 3.421875 -0.765625 3.71875 -0.847656 3.996094 -1.011719 C 4.273438 -1.171875 4.46875 -1.394531 4.585938 -1.671875 C 4.699219 -1.953125 4.757812 -2.359375 4.757812 -2.890625 L 4.757812 -6.222656 L 5.8125 -6.222656 L 5.8125 0 Z "/> +</symbol> +<symbol overflow="visible" id="glyph4-0"> +<path style="stroke:none;" d=""/> +</symbol> +<symbol overflow="visible" id="glyph4-1"> +<path style="stroke:none;" d="M 0.953125 0 L 0.953125 -9.304688 L 4.445312 -9.304688 C 5.15625 -9.304688 5.722656 -9.210938 6.152344 -9.023438 C 6.582031 -8.835938 6.921875 -8.546875 7.164062 -8.152344 C 7.40625 -7.761719 7.527344 -7.351562 7.527344 -6.925781 C 7.527344 -6.527344 7.421875 -6.152344 7.203125 -5.800781 C 6.988281 -5.449219 6.664062 -5.167969 6.226562 -4.953125 C 6.789062 -4.785156 7.222656 -4.503906 7.523438 -4.105469 C 7.828125 -3.707031 7.980469 -3.238281 7.980469 -2.699219 C 7.980469 -2.261719 7.886719 -1.855469 7.703125 -1.480469 C 7.519531 -1.105469 7.292969 -0.820312 7.019531 -0.617188 C 6.75 -0.414062 6.410156 -0.257812 6 -0.15625 C 5.59375 -0.0507812 5.09375 0 4.5 0 Z M 2.183594 -5.394531 L 4.195312 -5.394531 C 4.742188 -5.394531 5.132812 -5.429688 5.371094 -5.503906 C 5.683594 -5.597656 5.917969 -5.75 6.078125 -5.96875 C 6.238281 -6.183594 6.316406 -6.453125 6.316406 -6.78125 C 6.316406 -7.089844 6.242188 -7.359375 6.09375 -7.59375 C 5.945312 -7.828125 5.734375 -7.992188 5.460938 -8.078125 C 5.183594 -8.164062 4.710938 -8.207031 4.042969 -8.207031 L 2.183594 -8.207031 Z M 2.183594 -1.097656 L 4.5 -1.097656 C 4.898438 -1.097656 5.175781 -1.113281 5.339844 -1.140625 C 5.621094 -1.191406 5.859375 -1.277344 6.050781 -1.398438 C 6.242188 -1.515625 6.394531 -1.6875 6.519531 -1.914062 C 6.640625 -2.140625 6.703125 -2.402344 6.703125 -2.699219 C 6.703125 -3.046875 6.613281 -3.347656 6.4375 -3.601562 C 6.257812 -3.859375 6.011719 -4.039062 5.695312 -4.140625 C 5.382812 -4.246094 4.929688 -4.296875 4.335938 -4.296875 L 2.183594 -4.296875 Z "/> +</symbol> +<symbol overflow="visible" id="glyph4-2"> +<path style="stroke:none;" d="M 0.429688 -3.371094 C 0.429688 -4.617188 0.777344 -5.542969 1.472656 -6.144531 C 2.050781 -6.644531 2.757812 -6.894531 3.59375 -6.894531 C 4.519531 -6.894531 5.277344 -6.589844 5.867188 -5.984375 C 6.453125 -5.375 6.746094 -4.535156 6.746094 -3.464844 C 6.746094 -2.597656 6.617188 -1.914062 6.355469 -1.417969 C 6.097656 -0.921875 5.71875 -0.535156 5.222656 -0.261719 C 4.722656 0.015625 4.179688 0.152344 3.59375 0.152344 C 2.648438 0.152344 1.886719 -0.148438 1.304688 -0.753906 C 0.722656 -1.359375 0.429688 -2.230469 0.429688 -3.371094 Z M 1.605469 -3.371094 C 1.605469 -2.507812 1.792969 -1.859375 2.171875 -1.429688 C 2.546875 -1 3.023438 -0.789062 3.59375 -0.789062 C 4.160156 -0.789062 4.632812 -1.003906 5.007812 -1.433594 C 5.382812 -1.867188 5.574219 -2.523438 5.574219 -3.410156 C 5.574219 -4.242188 5.382812 -4.875 5.003906 -5.304688 C 4.625 -5.734375 4.15625 -5.949219 3.59375 -5.949219 C 3.023438 -5.949219 2.546875 -5.734375 2.171875 -5.304688 C 1.792969 -4.878906 1.605469 -4.234375 1.605469 -3.371094 Z "/> +</symbol> +<symbol overflow="visible" id="glyph4-3"> +<path style="stroke:none;" d="M 0.398438 -2.011719 L 1.53125 -2.191406 C 1.59375 -1.738281 1.769531 -1.390625 2.058594 -1.148438 C 2.347656 -0.90625 2.753906 -0.789062 3.273438 -0.789062 C 3.800781 -0.789062 4.1875 -0.894531 4.445312 -1.109375 C 4.699219 -1.320312 4.824219 -1.570312 4.824219 -1.859375 C 4.824219 -2.117188 4.710938 -2.320312 4.488281 -2.46875 C 4.332031 -2.570312 3.941406 -2.699219 3.320312 -2.855469 C 2.480469 -3.066406 1.902344 -3.25 1.578125 -3.40625 C 1.253906 -3.558594 1.007812 -3.773438 0.839844 -4.046875 C 0.671875 -4.320312 0.589844 -4.621094 0.589844 -4.953125 C 0.589844 -5.253906 0.660156 -5.53125 0.796875 -5.785156 C 0.933594 -6.042969 1.121094 -6.253906 1.359375 -6.421875 C 1.535156 -6.554688 1.777344 -6.667969 2.085938 -6.757812 C 2.390625 -6.847656 2.722656 -6.894531 3.070312 -6.894531 C 3.601562 -6.894531 4.066406 -6.816406 4.464844 -6.664062 C 4.867188 -6.511719 5.160156 -6.304688 5.351562 -6.046875 C 5.542969 -5.785156 5.671875 -5.4375 5.746094 -5 L 4.628906 -4.851562 C 4.578125 -5.195312 4.429688 -5.46875 4.1875 -5.664062 C 3.945312 -5.859375 3.597656 -5.953125 3.15625 -5.953125 C 2.628906 -5.953125 2.253906 -5.867188 2.03125 -5.695312 C 1.808594 -5.519531 1.695312 -5.316406 1.695312 -5.085938 C 1.695312 -4.9375 1.742188 -4.804688 1.835938 -4.683594 C 1.929688 -4.5625 2.074219 -4.460938 2.273438 -4.378906 C 2.386719 -4.335938 2.722656 -4.242188 3.28125 -4.085938 C 4.089844 -3.871094 4.652344 -3.695312 4.972656 -3.558594 C 5.292969 -3.421875 5.542969 -3.21875 5.726562 -2.957031 C 5.90625 -2.695312 6 -2.371094 6 -1.980469 C 6 -1.601562 5.886719 -1.242188 5.664062 -0.90625 C 5.441406 -0.570312 5.121094 -0.308594 4.703125 -0.125 C 4.285156 0.0585938 3.8125 0.152344 3.28125 0.152344 C 2.40625 0.152344 1.738281 -0.03125 1.277344 -0.394531 C 0.820312 -0.757812 0.527344 -1.296875 0.398438 -2.011719 Z "/> +</symbol> +<symbol overflow="visible" id="glyph4-4"> +<path style="stroke:none;" d="M 3.351562 -1.023438 L 3.515625 -0.0117188 C 3.195312 0.0546875 2.90625 0.0898438 2.652344 0.0898438 C 2.238281 0.0898438 1.917969 0.0234375 1.6875 -0.109375 C 1.460938 -0.238281 1.300781 -0.410156 1.207031 -0.625 C 1.113281 -0.839844 1.066406 -1.289062 1.066406 -1.972656 L 1.066406 -5.851562 L 0.226562 -5.851562 L 0.226562 -6.742188 L 1.066406 -6.742188 L 1.066406 -8.410156 L 2.203125 -9.097656 L 2.203125 -6.742188 L 3.351562 -6.742188 L 3.351562 -5.851562 L 2.203125 -5.851562 L 2.203125 -1.910156 C 2.203125 -1.585938 2.222656 -1.375 2.261719 -1.28125 C 2.304688 -1.1875 2.367188 -1.113281 2.460938 -1.058594 C 2.550781 -1.003906 2.679688 -0.976562 2.851562 -0.976562 C 2.976562 -0.976562 3.144531 -0.992188 3.351562 -1.023438 Z "/> +</symbol> +<symbol overflow="visible" id="glyph4-5"> +<path style="stroke:none;" d="M 1.179688 0 L 1.179688 -1.300781 L 2.480469 -1.300781 L 2.480469 0 Z "/> +</symbol> +<symbol overflow="visible" id="glyph4-6"> +<path style="stroke:none;" d="M 1.003906 0 L 1.003906 -9.304688 L 4.511719 -9.304688 C 5.128906 -9.304688 5.601562 -9.277344 5.929688 -9.21875 C 6.386719 -9.140625 6.769531 -8.996094 7.078125 -8.78125 C 7.386719 -8.566406 7.636719 -8.269531 7.824219 -7.882812 C 8.011719 -7.5 8.105469 -7.074219 8.105469 -6.613281 C 8.105469 -5.824219 7.855469 -5.152344 7.351562 -4.605469 C 6.847656 -4.058594 5.9375 -3.78125 4.621094 -3.78125 L 2.234375 -3.78125 L 2.234375 0 Z M 2.234375 -4.882812 L 4.640625 -4.882812 C 5.4375 -4.882812 6 -5.03125 6.335938 -5.324219 C 6.667969 -5.621094 6.835938 -6.039062 6.835938 -6.578125 C 6.835938 -6.964844 6.738281 -7.296875 6.542969 -7.574219 C 6.34375 -7.851562 6.085938 -8.035156 5.765625 -8.125 C 5.558594 -8.179688 5.171875 -8.207031 4.613281 -8.207031 L 2.234375 -8.207031 Z "/> +</symbol> +<symbol overflow="visible" id="glyph4-7"> +<path style="stroke:none;" d="M 0.804688 2.597656 L 0.679688 1.523438 C 0.929688 1.589844 1.148438 1.625 1.332031 1.625 C 1.585938 1.625 1.789062 1.582031 1.941406 1.5 C 2.09375 1.414062 2.21875 1.296875 2.316406 1.140625 C 2.390625 1.027344 2.503906 0.746094 2.664062 0.292969 C 2.6875 0.230469 2.722656 0.136719 2.765625 0.0117188 L 0.210938 -6.742188 L 1.441406 -6.742188 L 2.84375 -2.835938 C 3.027344 -2.34375 3.1875 -1.820312 3.332031 -1.277344 C 3.464844 -1.800781 3.621094 -2.3125 3.800781 -2.8125 L 5.242188 -6.742188 L 6.386719 -6.742188 L 3.820312 0.113281 C 3.546875 0.855469 3.332031 1.363281 3.179688 1.644531 C 2.976562 2.019531 2.746094 2.296875 2.480469 2.472656 C 2.21875 2.648438 1.90625 2.734375 1.542969 2.734375 C 1.324219 2.734375 1.078125 2.6875 0.804688 2.597656 Z "/> +</symbol> +<symbol overflow="visible" id="glyph4-8"> +<path style="stroke:none;" d="M 0.855469 0 L 0.855469 -9.304688 L 2 -9.304688 L 2 -5.96875 C 2.53125 -6.585938 3.207031 -6.894531 4.019531 -6.894531 C 4.519531 -6.894531 4.953125 -6.796875 5.320312 -6.597656 C 5.6875 -6.402344 5.949219 -6.128906 6.109375 -5.78125 C 6.269531 -5.433594 6.347656 -4.933594 6.347656 -4.273438 L 6.347656 0 L 5.203125 0 L 5.203125 -4.273438 C 5.203125 -4.84375 5.082031 -5.257812 4.832031 -5.519531 C 4.585938 -5.78125 4.234375 -5.910156 3.78125 -5.910156 C 3.445312 -5.910156 3.125 -5.820312 2.828125 -5.644531 C 2.53125 -5.46875 2.316406 -5.234375 2.191406 -4.933594 C 2.0625 -4.632812 2 -4.21875 2 -3.6875 L 2 0 Z "/> +</symbol> +<symbol overflow="visible" id="glyph4-9"> +<path style="stroke:none;" d="M 0.855469 0 L 0.855469 -6.742188 L 1.886719 -6.742188 L 1.886719 -5.78125 C 2.382812 -6.523438 3.09375 -6.894531 4.03125 -6.894531 C 4.4375 -6.894531 4.808594 -6.820312 5.152344 -6.675781 C 5.492188 -6.527344 5.746094 -6.335938 5.914062 -6.101562 C 6.085938 -5.863281 6.203125 -5.582031 6.273438 -5.257812 C 6.3125 -5.046875 6.335938 -4.675781 6.335938 -4.144531 L 6.335938 0 L 5.191406 0 L 5.191406 -4.101562 C 5.191406 -4.566406 5.148438 -4.914062 5.058594 -5.144531 C 4.96875 -5.375 4.8125 -5.558594 4.585938 -5.695312 C 4.359375 -5.835938 4.09375 -5.902344 3.789062 -5.902344 C 3.304688 -5.902344 2.882812 -5.75 2.53125 -5.441406 C 2.175781 -5.132812 2 -4.546875 2 -3.679688 L 2 0 Z "/> +</symbol> +<symbol overflow="visible" id="glyph4-10"> +<path style="stroke:none;" d="M 0.855469 2.582031 L 0.855469 -6.742188 L 1.898438 -6.742188 L 1.898438 -5.867188 C 2.144531 -6.207031 2.421875 -6.464844 2.730469 -6.636719 C 3.039062 -6.808594 3.414062 -6.894531 3.851562 -6.894531 C 4.429688 -6.894531 4.9375 -6.746094 5.375 -6.449219 C 5.816406 -6.152344 6.148438 -5.734375 6.375 -5.195312 C 6.597656 -4.65625 6.710938 -4.066406 6.710938 -3.421875 C 6.710938 -2.730469 6.585938 -2.109375 6.339844 -1.558594 C 6.089844 -1.007812 5.730469 -0.582031 5.257812 -0.289062 C 4.785156 0.00390625 4.289062 0.152344 3.769531 0.152344 C 3.390625 0.152344 3.046875 0.0703125 2.746094 -0.0898438 C 2.441406 -0.25 2.195312 -0.453125 2 -0.699219 L 2 2.582031 Z M 1.890625 -3.332031 C 1.890625 -2.464844 2.066406 -1.824219 2.417969 -1.410156 C 2.769531 -0.996094 3.195312 -0.789062 3.695312 -0.789062 C 4.203125 -0.789062 4.636719 -1 5 -1.429688 C 5.359375 -1.859375 5.542969 -2.527344 5.542969 -3.429688 C 5.542969 -4.289062 5.363281 -4.929688 5.011719 -5.359375 C 4.65625 -5.785156 4.234375 -6 3.746094 -6 C 3.257812 -6 2.828125 -5.769531 2.453125 -5.316406 C 2.078125 -4.859375 1.890625 -4.199219 1.890625 -3.332031 Z "/> +</symbol> +<symbol overflow="visible" id="glyph4-11"> +<path style="stroke:none;" d="M 1.910156 0 L 0.851562 0 L 0.851562 -9.304688 L 1.992188 -9.304688 L 1.992188 -5.984375 C 2.476562 -6.589844 3.089844 -6.894531 3.839844 -6.894531 C 4.253906 -6.894531 4.648438 -6.808594 5.019531 -6.644531 C 5.390625 -6.476562 5.691406 -6.242188 5.933594 -5.9375 C 6.171875 -5.636719 6.359375 -5.269531 6.492188 -4.84375 C 6.628906 -4.414062 6.695312 -3.957031 6.695312 -3.472656 C 6.695312 -2.316406 6.410156 -1.425781 5.839844 -0.792969 C 5.269531 -0.164062 4.582031 0.152344 3.78125 0.152344 C 2.988281 0.152344 2.363281 -0.179688 1.910156 -0.84375 Z M 1.898438 -3.421875 C 1.898438 -2.613281 2.007812 -2.027344 2.226562 -1.667969 C 2.585938 -1.082031 3.074219 -0.789062 3.6875 -0.789062 C 4.1875 -0.789062 4.617188 -1.003906 4.984375 -1.4375 C 5.347656 -1.871094 5.527344 -2.519531 5.527344 -3.375 C 5.527344 -4.257812 5.355469 -4.90625 5.003906 -5.324219 C 4.65625 -5.742188 4.234375 -5.953125 3.738281 -5.953125 C 3.238281 -5.953125 2.808594 -5.738281 2.445312 -5.304688 C 2.082031 -4.871094 1.898438 -4.242188 1.898438 -3.421875 Z "/> +</symbol> +<symbol overflow="visible" id="glyph4-12"> +<path style="stroke:none;" d="M 0.863281 -7.992188 L 0.863281 -9.304688 L 2.007812 -9.304688 L 2.007812 -7.992188 Z M 0.863281 0 L 0.863281 -6.742188 L 2.007812 -6.742188 L 2.007812 0 Z "/> +</symbol> +<symbol overflow="visible" id="glyph4-13"> +<path style="stroke:none;" d="M 5.230469 0 L 5.230469 -0.851562 C 4.804688 -0.183594 4.175781 0.152344 3.34375 0.152344 C 2.808594 0.152344 2.3125 0.00390625 1.863281 -0.292969 C 1.414062 -0.589844 1.0625 -1 0.816406 -1.53125 C 0.570312 -2.0625 0.445312 -2.675781 0.445312 -3.363281 C 0.445312 -4.035156 0.554688 -4.648438 0.78125 -5.195312 C 1.003906 -5.742188 1.339844 -6.164062 1.789062 -6.457031 C 2.238281 -6.75 2.738281 -6.894531 3.292969 -6.894531 C 3.699219 -6.894531 4.0625 -6.808594 4.378906 -6.636719 C 4.695312 -6.464844 4.957031 -6.242188 5.15625 -5.96875 L 5.15625 -9.304688 L 6.289062 -9.304688 L 6.289062 0 Z M 1.617188 -3.363281 C 1.617188 -2.5 1.800781 -1.855469 2.164062 -1.429688 C 2.527344 -1 2.957031 -0.789062 3.453125 -0.789062 C 3.953125 -0.789062 4.375 -0.992188 4.726562 -1.398438 C 5.074219 -1.808594 5.25 -2.429688 5.25 -3.269531 C 5.25 -4.191406 5.070312 -4.867188 4.714844 -5.300781 C 4.359375 -5.730469 3.921875 -5.949219 3.402344 -5.949219 C 2.894531 -5.949219 2.46875 -5.742188 2.128906 -5.324219 C 1.789062 -4.910156 1.617188 -4.257812 1.617188 -3.363281 Z "/> +</symbol> +<symbol overflow="visible" id="glyph4-14"> +<path style="stroke:none;" d="M 4.84375 0 L 3.699219 0 L 3.699219 -7.28125 C 3.425781 -7.019531 3.066406 -6.757812 2.617188 -6.492188 C 2.171875 -6.230469 1.769531 -6.035156 1.414062 -5.902344 L 1.414062 -7.007812 C 2.054688 -7.308594 2.613281 -7.671875 3.089844 -8.101562 C 3.570312 -8.527344 3.90625 -8.941406 4.105469 -9.34375 L 4.84375 -9.34375 Z "/> +</symbol> +</g> +<clipPath id="clip1"> + <path d="M 94 19 L 96 19 L 96 215 L 94 215 Z "/> +</clipPath> +<clipPath id="clip2"> + <path d="M 204 19 L 206 19 L 206 215 L 204 215 Z "/> +</clipPath> +<clipPath id="clip3"> + <path d="M 314 19 L 316 19 L 316 215 L 314 215 Z "/> +</clipPath> +<clipPath id="clip4"> + <path d="M 39 171 L 355 171 L 355 173 L 39 173 Z "/> +</clipPath> +<clipPath id="clip5"> + <path d="M 39 107 L 355 107 L 355 109 L 39 109 Z "/> +</clipPath> +<clipPath id="clip6"> + <path d="M 39 44 L 355 44 L 355 46 L 39 46 Z "/> +</clipPath> +</defs> +<g id="surface18"> +<g clip-path="url(#clip1)" clip-rule="nonzero"> +<path style="fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:0.5;stroke-dasharray:1,2;stroke-miterlimit:3.25;" d="M 95.160156 214.296875 L 95.160156 19 "/> +</g> +<g clip-path="url(#clip2)" clip-rule="nonzero"> +<path style="fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:0.5;stroke-dasharray:1,2;stroke-miterlimit:3.25;" d="M 204.84375 214.296875 L 204.84375 19 "/> +</g> +<g clip-path="url(#clip3)" clip-rule="nonzero"> +<path style="fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:0.5;stroke-dasharray:1,2;stroke-miterlimit:3.25;" d="M 314.53125 214.296875 L 314.53125 19 "/> +</g> +<g clip-path="url(#clip4)" clip-rule="nonzero"> +<path style="fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:0.5;stroke-dasharray:1,2;stroke-miterlimit:3.25;" d="M 39 171.960938 L 355 171.960938 "/> +</g> +<g clip-path="url(#clip5)" clip-rule="nonzero"> +<path style="fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:0.5;stroke-dasharray:1,2;stroke-miterlimit:3.25;" d="M 39 108.234375 L 355 108.234375 "/> +</g> +<g clip-path="url(#clip6)" clip-rule="nonzero"> +<path style="fill:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:0.5;stroke-dasharray:1,2;stroke-miterlimit:3.25;" d="M 39 44.511719 L 355 44.511719 "/> +</g> +<path style=" stroke:none;fill-rule:evenodd;fill:rgb(36.84082%,50.67749%,70.979309%);fill-opacity:1;" d="M 55.070312 201 C 55.070312 200.183594 54.75 199.402344 54.171875 198.828125 C 53.597656 198.25 52.816406 197.929688 52 197.929688 C 51.183594 197.929688 50.402344 198.25 49.828125 198.828125 C 49.25 199.402344 48.929688 200.183594 48.929688 201 C 48.929688 201.816406 49.25 202.597656 49.828125 203.171875 C 50.402344 203.75 51.183594 204.070312 52 204.070312 C 52.816406 204.070312 53.597656 203.75 54.171875 203.171875 C 54.75 202.597656 55.070312 201.816406 55.070312 201 Z "/> +<path style=" stroke:none;fill-rule:evenodd;fill:rgb(36.84082%,50.67749%,70.979309%);fill-opacity:1;" d="M 88.070312 176 C 88.070312 175.183594 87.75 174.402344 87.171875 173.828125 C 86.597656 173.25 85.816406 172.929688 85 172.929688 C 84.183594 172.929688 83.402344 173.25 82.828125 173.828125 C 82.25 174.402344 81.929688 175.183594 81.929688 176 C 81.929688 176.816406 82.25 177.597656 82.828125 178.171875 C 83.402344 178.75 84.183594 179.070312 85 179.070312 C 85.816406 179.070312 86.597656 178.75 87.171875 178.171875 C 87.75 177.597656 88.070312 176.816406 88.070312 176 Z "/> +<path style=" stroke:none;fill-rule:evenodd;fill:rgb(36.84082%,50.67749%,70.979309%);fill-opacity:1;" d="M 121.070312 160 C 121.070312 159.183594 120.75 158.402344 120.171875 157.828125 C 119.597656 157.25 118.816406 156.929688 118 156.929688 C 117.183594 156.929688 116.402344 157.25 115.828125 157.828125 C 115.25 158.402344 114.929688 159.183594 114.929688 160 C 114.929688 160.816406 115.25 161.597656 115.828125 162.171875 C 116.402344 162.75 117.183594 163.070312 118 163.070312 C 118.816406 163.070312 119.597656 162.75 120.171875 162.171875 C 120.75 161.597656 121.070312 160.816406 121.070312 160 Z "/> +<path style=" stroke:none;fill-rule:evenodd;fill:rgb(36.84082%,50.67749%,70.979309%);fill-opacity:1;" d="M 154.070312 142 C 154.070312 141.183594 153.75 140.402344 153.171875 139.828125 C 152.597656 139.25 151.816406 138.929688 151 138.929688 C 150.183594 138.929688 149.402344 139.25 148.828125 139.828125 C 148.25 140.402344 147.929688 141.183594 147.929688 142 C 147.929688 142.816406 148.25 143.597656 148.828125 144.171875 C 149.402344 144.75 150.183594 145.070312 151 145.070312 C 151.816406 145.070312 152.597656 144.75 153.171875 144.171875 C 153.75 143.597656 154.070312 142.816406 154.070312 142 Z "/> +<path style=" stroke:none;fill-rule:evenodd;fill:rgb(36.84082%,50.67749%,70.979309%);fill-opacity:1;" d="M 187.070312 124 C 187.070312 123.183594 186.75 122.402344 186.171875 121.828125 C 185.597656 121.25 184.816406 120.929688 184 120.929688 C 183.183594 120.929688 182.402344 121.25 181.828125 121.828125 C 181.25 122.402344 180.929688 123.183594 180.929688 124 C 180.929688 124.816406 181.25 125.597656 181.828125 126.171875 C 182.402344 126.75 183.183594 127.070312 184 127.070312 C 184.816406 127.070312 185.597656 126.75 186.171875 126.171875 C 186.75 125.597656 187.070312 124.816406 187.070312 124 Z "/> +<path style=" stroke:none;fill-rule:evenodd;fill:rgb(36.84082%,50.67749%,70.979309%);fill-opacity:1;" d="M 220.070312 105 C 220.070312 104.183594 219.75 103.402344 219.171875 102.828125 C 218.597656 102.25 217.816406 101.929688 217 101.929688 C 216.183594 101.929688 215.402344 102.25 214.828125 102.828125 C 214.25 103.402344 213.929688 104.183594 213.929688 105 C 213.929688 105.816406 214.25 106.597656 214.828125 107.171875 C 215.402344 107.75 216.183594 108.070312 217 108.070312 C 217.816406 108.070312 218.597656 107.75 219.171875 107.171875 C 219.75 106.597656 220.070312 105.816406 220.070312 105 Z "/> +<path style=" stroke:none;fill-rule:evenodd;fill:rgb(36.84082%,50.67749%,70.979309%);fill-opacity:1;" d="M 253.070312 86 C 253.070312 85.183594 252.75 84.402344 252.171875 83.828125 C 251.597656 83.25 250.816406 82.929688 250 82.929688 C 249.183594 82.929688 248.402344 83.25 247.828125 83.828125 C 247.25 84.402344 246.929688 85.183594 246.929688 86 C 246.929688 86.816406 247.25 87.597656 247.828125 88.171875 C 248.402344 88.75 249.183594 89.070312 250 89.070312 C 250.816406 89.070312 251.597656 88.75 252.171875 88.171875 C 252.75 87.597656 253.070312 86.816406 253.070312 86 Z "/> +<path style=" stroke:none;fill-rule:evenodd;fill:rgb(36.84082%,50.67749%,70.979309%);fill-opacity:1;" d="M 286.070312 67 C 286.070312 66.183594 285.75 65.402344 285.171875 64.828125 C 284.597656 64.25 283.816406 63.929688 283 63.929688 C 282.183594 63.929688 281.402344 64.25 280.828125 64.828125 C 280.25 65.402344 279.929688 66.183594 279.929688 67 C 279.929688 67.816406 280.25 68.597656 280.828125 69.171875 C 281.402344 69.75 282.183594 70.070312 283 70.070312 C 283.816406 70.070312 284.597656 69.75 285.171875 69.171875 C 285.75 68.597656 286.070312 67.816406 286.070312 67 Z "/> +<path style=" stroke:none;fill-rule:evenodd;fill:rgb(36.84082%,50.67749%,70.979309%);fill-opacity:1;" d="M 319.070312 48 C 319.070312 47.183594 318.75 46.402344 318.171875 45.828125 C 317.597656 45.25 316.816406 44.929688 316 44.929688 C 315.183594 44.929688 314.402344 45.25 313.828125 45.828125 C 313.25 46.402344 312.929688 47.183594 312.929688 48 C 312.929688 48.816406 313.25 49.597656 313.828125 50.171875 C 314.402344 50.75 315.183594 51.070312 316 51.070312 C 316.816406 51.070312 317.597656 50.75 318.171875 50.171875 C 318.75 49.597656 319.070312 48.816406 319.070312 48 Z "/> +<path style=" stroke:none;fill-rule:evenodd;fill:rgb(36.84082%,50.67749%,70.979309%);fill-opacity:1;" d="M 352.070312 29 C 352.070312 28.183594 351.75 27.402344 351.171875 26.828125 C 350.597656 26.25 349.816406 25.929688 349 25.929688 C 348.183594 25.929688 347.402344 26.25 346.828125 26.828125 C 346.25 27.402344 345.929688 28.183594 345.929688 29 C 345.929688 29.816406 346.25 30.597656 346.828125 31.171875 C 347.402344 31.75 348.183594 32.070312 349 32.070312 C 349.816406 32.070312 350.597656 31.75 351.171875 31.171875 C 351.75 30.597656 352.070312 29.816406 352.070312 29 Z "/> +<path style=" stroke:none;fill-rule:evenodd;fill:rgb(88.070679%,61.103821%,14.204407%);fill-opacity:1;" d="M 55.070312 191 C 55.070312 190.183594 54.75 189.402344 54.171875 188.828125 C 53.597656 188.25 52.816406 187.929688 52 187.929688 C 51.183594 187.929688 50.402344 188.25 49.828125 188.828125 C 49.25 189.402344 48.929688 190.183594 48.929688 191 C 48.929688 191.816406 49.25 192.597656 49.828125 193.171875 C 50.402344 193.75 51.183594 194.070312 52 194.070312 C 52.816406 194.070312 53.597656 193.75 54.171875 193.171875 C 54.75 192.597656 55.070312 191.816406 55.070312 191 Z "/> +<path style=" stroke:none;fill-rule:evenodd;fill:rgb(88.070679%,61.103821%,14.204407%);fill-opacity:1;" d="M 88.070312 181 C 88.070312 180.183594 87.75 179.402344 87.171875 178.828125 C 86.597656 178.25 85.816406 177.929688 85 177.929688 C 84.183594 177.929688 83.402344 178.25 82.828125 178.828125 C 82.25 179.402344 81.929688 180.183594 81.929688 181 C 81.929688 181.816406 82.25 182.597656 82.828125 183.171875 C 83.402344 183.75 84.183594 184.070312 85 184.070312 C 85.816406 184.070312 86.597656 183.75 87.171875 183.171875 C 87.75 182.597656 88.070312 181.816406 88.070312 181 Z "/> +<path style=" stroke:none;fill-rule:evenodd;fill:rgb(88.070679%,61.103821%,14.204407%);fill-opacity:1;" d="M 121.070312 170 C 121.070312 169.183594 120.75 168.402344 120.171875 167.828125 C 119.597656 167.25 118.816406 166.929688 118 166.929688 C 117.183594 166.929688 116.402344 167.25 115.828125 167.828125 C 115.25 168.402344 114.929688 169.183594 114.929688 170 C 114.929688 170.816406 115.25 171.597656 115.828125 172.171875 C 116.402344 172.75 117.183594 173.070312 118 173.070312 C 118.816406 173.070312 119.597656 172.75 120.171875 172.171875 C 120.75 171.597656 121.070312 170.816406 121.070312 170 Z "/> +<path style=" stroke:none;fill-rule:evenodd;fill:rgb(88.070679%,61.103821%,14.204407%);fill-opacity:1;" d="M 154.070312 157 C 154.070312 156.183594 153.75 155.402344 153.171875 154.828125 C 152.597656 154.25 151.816406 153.929688 151 153.929688 C 150.183594 153.929688 149.402344 154.25 148.828125 154.828125 C 148.25 155.402344 147.929688 156.183594 147.929688 157 C 147.929688 157.816406 148.25 158.597656 148.828125 159.171875 C 149.402344 159.75 150.183594 160.070312 151 160.070312 C 151.816406 160.070312 152.597656 159.75 153.171875 159.171875 C 153.75 158.597656 154.070312 157.816406 154.070312 157 Z "/> +<path style=" stroke:none;fill-rule:evenodd;fill:rgb(88.070679%,61.103821%,14.204407%);fill-opacity:1;" d="M 187.070312 142 C 187.070312 141.183594 186.75 140.402344 186.171875 139.828125 C 185.597656 139.25 184.816406 138.929688 184 138.929688 C 183.183594 138.929688 182.402344 139.25 181.828125 139.828125 C 181.25 140.402344 180.929688 141.183594 180.929688 142 C 180.929688 142.816406 181.25 143.597656 181.828125 144.171875 C 182.402344 144.75 183.183594 145.070312 184 145.070312 C 184.816406 145.070312 185.597656 144.75 186.171875 144.171875 C 186.75 143.597656 187.070312 142.816406 187.070312 142 Z "/> +<path style=" stroke:none;fill-rule:evenodd;fill:rgb(88.070679%,61.103821%,14.204407%);fill-opacity:1;" d="M 220.070312 125 C 220.070312 124.183594 219.75 123.402344 219.171875 122.828125 C 218.597656 122.25 217.816406 121.929688 217 121.929688 C 216.183594 121.929688 215.402344 122.25 214.828125 122.828125 C 214.25 123.402344 213.929688 124.183594 213.929688 125 C 213.929688 125.816406 214.25 126.597656 214.828125 127.171875 C 215.402344 127.75 216.183594 128.070312 217 128.070312 C 217.816406 128.070312 218.597656 127.75 219.171875 127.171875 C 219.75 126.597656 220.070312 125.816406 220.070312 125 Z "/> +<path style=" stroke:none;fill-rule:evenodd;fill:rgb(88.070679%,61.103821%,14.204407%);fill-opacity:1;" d="M 253.070312 107 C 253.070312 106.183594 252.75 105.402344 252.171875 104.828125 C 251.597656 104.25 250.816406 103.929688 250 103.929688 C 249.183594 103.929688 248.402344 104.25 247.828125 104.828125 C 247.25 105.402344 246.929688 106.183594 246.929688 107 C 246.929688 107.816406 247.25 108.597656 247.828125 109.171875 C 248.402344 109.75 249.183594 110.070312 250 110.070312 C 250.816406 110.070312 251.597656 109.75 252.171875 109.171875 C 252.75 108.597656 253.070312 107.816406 253.070312 107 Z "/> +<path style=" stroke:none;fill-rule:evenodd;fill:rgb(88.070679%,61.103821%,14.204407%);fill-opacity:1;" d="M 286.070312 88 C 286.070312 87.183594 285.75 86.402344 285.171875 85.828125 C 284.597656 85.25 283.816406 84.929688 283 84.929688 C 282.183594 84.929688 281.402344 85.25 280.828125 85.828125 C 280.25 86.402344 279.929688 87.183594 279.929688 88 C 279.929688 88.816406 280.25 89.597656 280.828125 90.171875 C 281.402344 90.75 282.183594 91.070312 283 91.070312 C 283.816406 91.070312 284.597656 90.75 285.171875 90.171875 C 285.75 89.597656 286.070312 88.816406 286.070312 88 Z "/> +<path style=" stroke:none;fill-rule:evenodd;fill:rgb(88.070679%,61.103821%,14.204407%);fill-opacity:1;" d="M 319.070312 69 C 319.070312 68.183594 318.75 67.402344 318.171875 66.828125 C 317.597656 66.25 316.816406 65.929688 316 65.929688 C 315.183594 65.929688 314.402344 66.25 313.828125 66.828125 C 313.25 67.402344 312.929688 68.183594 312.929688 69 C 312.929688 69.816406 313.25 70.597656 313.828125 71.171875 C 314.402344 71.75 315.183594 72.070312 316 72.070312 C 316.816406 72.070312 317.597656 71.75 318.171875 71.171875 C 318.75 70.597656 319.070312 69.816406 319.070312 69 Z "/> +<path style=" stroke:none;fill-rule:evenodd;fill:rgb(88.070679%,61.103821%,14.204407%);fill-opacity:1;" d="M 352.070312 50 C 352.070312 49.183594 351.75 48.402344 351.171875 47.828125 C 350.597656 47.25 349.816406 46.929688 349 46.929688 C 348.183594 46.929688 347.402344 47.25 346.828125 47.828125 C 346.25 48.402344 345.929688 49.183594 345.929688 50 C 345.929688 50.816406 346.25 51.597656 346.828125 52.171875 C 347.402344 52.75 348.183594 53.070312 349 53.070312 C 349.816406 53.070312 350.597656 52.75 351.171875 52.171875 C 351.75 51.597656 352.070312 50.816406 352.070312 50 Z "/> +<path style="fill:none;stroke-width:0.5;stroke-linecap:square;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 214.296875 L 39 214.296875 "/> +<path style="fill:none;stroke-width:0.5;stroke-linecap:square;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 39 214.296875 L 39 19 "/> +<path style="fill:none;stroke-width:0.5;stroke-linecap:square;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 39 19 L 355 19 "/> +<path style="fill:none;stroke-width:0.5;stroke-linecap:square;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 19 L 355 214.296875 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 95.160156 214.296875 L 95.160156 211.140625 "/> +<g style="fill:rgb(39.99939%,39.99939%,39.99939%);fill-opacity:1;"> + <use xlink:href="#glyph0-1" x="89.659467" y="226.29874"/> + <use xlink:href="#glyph0-2" x="95.220991" y="226.29874"/> +</g> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 204.84375 214.296875 L 204.84375 211.140625 "/> +<g style="fill:rgb(39.99939%,39.99939%,39.99939%);fill-opacity:1;"> + <use xlink:href="#glyph0-1" x="196.345465" y="226.29874"/> + <use xlink:href="#glyph0-2" x="201.906989" y="226.29874"/> + <use xlink:href="#glyph0-2" x="207.468512" y="226.29874"/> +</g> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 314.53125 214.296875 L 314.53125 211.140625 "/> +<g style="fill:rgb(39.99939%,39.99939%,39.99939%);fill-opacity:1;"> + <use xlink:href="#glyph0-1" x="303.531463" y="226.29874"/> + <use xlink:href="#glyph0-2" x="309.092987" y="226.29874"/> + <use xlink:href="#glyph0-2" x="314.65451" y="226.29874"/> + <use xlink:href="#glyph0-2" x="320.216034" y="226.29874"/> +</g> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 51.511719 214.296875 L 51.511719 212.71875 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 62.140625 214.296875 L 62.140625 212.71875 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 70.824219 214.296875 L 70.824219 212.71875 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 78.167969 214.296875 L 78.167969 212.71875 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 84.53125 214.296875 L 84.53125 212.71875 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 90.140625 214.296875 L 90.140625 212.71875 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 128.179688 214.296875 L 128.179688 212.71875 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 147.492188 214.296875 L 147.492188 212.71875 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 161.195312 214.296875 L 161.195312 212.71875 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 171.828125 214.296875 L 171.828125 212.71875 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 180.511719 214.296875 L 180.511719 212.71875 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 187.855469 214.296875 L 187.855469 212.71875 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 194.214844 214.296875 L 194.214844 212.71875 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 199.828125 214.296875 L 199.828125 212.71875 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 237.863281 214.296875 L 237.863281 212.71875 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 257.179688 214.296875 L 257.179688 212.71875 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 270.882812 214.296875 L 270.882812 212.71875 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 281.511719 214.296875 L 281.511719 212.71875 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 290.199219 214.296875 L 290.199219 212.71875 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 297.539062 214.296875 L 297.539062 212.71875 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 303.902344 214.296875 L 303.902344 212.71875 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 309.511719 214.296875 L 309.511719 212.71875 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 347.550781 214.296875 L 347.550781 212.71875 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 39 171.960938 L 42.160156 171.960938 "/> +<g style="fill:rgb(39.99939%,39.99939%,39.99939%);fill-opacity:1;"> + <use xlink:href="#glyph0-1" x="19" y="176.961688"/> + <use xlink:href="#glyph0-2" x="24.561523" y="176.961688"/> +</g> +<g style="fill:rgb(39.99939%,39.99939%,39.99939%);fill-opacity:1;"> + <use xlink:href="#glyph1-1" x="30" y="172.81325"/> +</g> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 39 108.234375 L 42.160156 108.234375 "/> +<g style="fill:rgb(39.99939%,39.99939%,39.99939%);fill-opacity:1;"> + <use xlink:href="#glyph0-1" x="19" y="113.23603"/> + <use xlink:href="#glyph0-2" x="24.561523" y="113.23603"/> +</g> +<g style="fill:rgb(39.99939%,39.99939%,39.99939%);fill-opacity:1;"> + <use xlink:href="#glyph1-2" x="30" y="109.087593"/> +</g> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 39 44.511719 L 42.160156 44.511719 "/> +<g style="fill:rgb(39.99939%,39.99939%,39.99939%);fill-opacity:1;"> + <use xlink:href="#glyph0-1" x="19" y="49.510373"/> + <use xlink:href="#glyph0-2" x="24.561523" y="49.510373"/> +</g> +<g style="fill:rgb(39.99939%,39.99939%,39.99939%);fill-opacity:1;"> + <use xlink:href="#glyph1-3" x="30" y="45.361936"/> +</g> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 39 205.28125 L 40.578125 205.28125 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 39 197.320312 L 40.578125 197.320312 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 39 191.144531 L 40.578125 191.144531 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 39 186.097656 L 40.578125 186.097656 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 39 181.832031 L 40.578125 181.832031 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 39 178.136719 L 40.578125 178.136719 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 39 174.878906 L 40.578125 174.878906 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 39 152.777344 L 40.578125 152.777344 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 39 141.558594 L 40.578125 141.558594 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 39 133.59375 L 40.578125 133.59375 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 39 127.417969 L 40.578125 127.417969 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 39 122.375 L 40.578125 122.375 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 39 118.105469 L 40.578125 118.105469 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 39 114.410156 L 40.578125 114.410156 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 39 111.152344 L 40.578125 111.152344 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 39 89.050781 L 40.578125 89.050781 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 39 77.832031 L 40.578125 77.832031 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 39 69.871094 L 40.578125 69.871094 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 39 63.695312 L 40.578125 63.695312 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 39 58.648438 L 40.578125 58.648438 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 39 54.382812 L 40.578125 54.382812 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 39 50.6875 L 40.578125 50.6875 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 39 47.425781 L 40.578125 47.425781 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 39 25.328125 L 40.578125 25.328125 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 95.160156 19 L 95.160156 22.160156 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 204.84375 19 L 204.84375 22.160156 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 314.53125 19 L 314.53125 22.160156 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 51.511719 19 L 51.511719 20.578125 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 62.140625 19 L 62.140625 20.578125 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 70.824219 19 L 70.824219 20.578125 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 78.167969 19 L 78.167969 20.578125 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 84.53125 19 L 84.53125 20.578125 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 90.140625 19 L 90.140625 20.578125 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 128.179688 19 L 128.179688 20.578125 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 147.492188 19 L 147.492188 20.578125 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 161.195312 19 L 161.195312 20.578125 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 171.828125 19 L 171.828125 20.578125 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 180.511719 19 L 180.511719 20.578125 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 187.855469 19 L 187.855469 20.578125 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 194.214844 19 L 194.214844 20.578125 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 199.828125 19 L 199.828125 20.578125 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 237.863281 19 L 237.863281 20.578125 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 257.179688 19 L 257.179688 20.578125 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 270.882812 19 L 270.882812 20.578125 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 281.511719 19 L 281.511719 20.578125 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 290.199219 19 L 290.199219 20.578125 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 297.539062 19 L 297.539062 20.578125 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 303.902344 19 L 303.902344 20.578125 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 309.511719 19 L 309.511719 20.578125 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 347.550781 19 L 347.550781 20.578125 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 171.960938 L 351.839844 171.960938 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 108.234375 L 351.839844 108.234375 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 44.511719 L 351.839844 44.511719 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 205.28125 L 353.421875 205.28125 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 197.320312 L 353.421875 197.320312 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 191.144531 L 353.421875 191.144531 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 186.097656 L 353.421875 186.097656 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 181.832031 L 353.421875 181.832031 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 178.136719 L 353.421875 178.136719 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 174.878906 L 353.421875 174.878906 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 152.777344 L 353.421875 152.777344 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 141.558594 L 353.421875 141.558594 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 133.59375 L 353.421875 133.59375 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 127.417969 L 353.421875 127.417969 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 122.375 L 353.421875 122.375 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 118.105469 L 353.421875 118.105469 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 114.410156 L 353.421875 114.410156 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 111.152344 L 353.421875 111.152344 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 89.050781 L 353.421875 89.050781 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 77.832031 L 353.421875 77.832031 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 69.871094 L 353.421875 69.871094 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 63.695312 L 353.421875 63.695312 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 58.648438 L 353.421875 58.648438 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 54.382812 L 353.421875 54.382812 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 50.6875 L 353.421875 50.6875 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 47.425781 L 353.421875 47.425781 "/> +<path style="fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(39.99939%,39.99939%,39.99939%);stroke-opacity:1;stroke-miterlimit:3.25;" d="M 355 25.328125 L 353.421875 25.328125 "/> +<g style="fill:rgb(39.99939%,39.99939%,39.99939%);fill-opacity:1;"> + <use xlink:href="#glyph0-3" x="175.5" y="245.29874"/> + <use xlink:href="#glyph0-4" x="181.608398" y="245.29874"/> + <use xlink:href="#glyph0-5" x="187.169922" y="245.29874"/> + <use xlink:href="#glyph0-6" x="192.731445" y="245.29874"/> + <use xlink:href="#glyph0-7" x="197.731445" y="245.29874"/> + <use xlink:href="#glyph0-8" x="200.509766" y="245.29874"/> + <use xlink:href="#glyph0-9" x="202.731445" y="245.29874"/> + <use xlink:href="#glyph0-5" x="208.292969" y="245.29874"/> + <use xlink:href="#glyph0-10" x="213.854492" y="245.29874"/> +</g> +<g style="fill:rgb(39.99939%,39.99939%,39.99939%);fill-opacity:1;"> + <use xlink:href="#glyph2-1" x="9" y="129.14937"/> + <use xlink:href="#glyph2-2" x="9" y="122.479448"/> + <use xlink:href="#glyph2-3" x="9" y="117.479448"/> + <use xlink:href="#glyph2-4" x="9" y="114.701128"/> + <use xlink:href="#glyph2-5" x="9" y="109.139605"/> +</g> +<g style="fill:rgb(39.99939%,39.99939%,39.99939%);fill-opacity:1;"> + <use xlink:href="#glyph3-1" x="148" y="12"/> + <use xlink:href="#glyph3-2" x="155.330078" y="12"/> + <use xlink:href="#glyph3-3" x="157.996094" y="12"/> + <use xlink:href="#glyph3-4" x="160.662109" y="12"/> +</g> +<g style="fill:rgb(39.99939%,39.99939%,39.99939%);fill-opacity:1;"> + <use xlink:href="#glyph3-5" x="170" y="12"/> + <use xlink:href="#glyph3-2" x="176" y="12"/> + <use xlink:href="#glyph3-6" x="178.666016" y="12"/> + <use xlink:href="#glyph3-4" x="184.666016" y="12"/> +</g> +<g style="fill:rgb(39.99939%,39.99939%,39.99939%);fill-opacity:1;"> + <use xlink:href="#glyph3-7" x="194" y="12"/> + <use xlink:href="#glyph3-8" x="200.673828" y="12"/> +</g> +<g style="fill:rgb(39.99939%,39.99939%,39.99939%);fill-opacity:1;"> + <use xlink:href="#glyph3-9" x="207" y="12"/> + <use xlink:href="#glyph3-7" x="216.996094" y="12"/> + <use xlink:href="#glyph3-10" x="223.669922" y="12"/> + <use xlink:href="#glyph3-11" x="230.34375" y="12"/> + <use xlink:href="#glyph3-3" x="237.017578" y="12"/> + <use xlink:href="#glyph3-4" x="239.683594" y="12"/> +</g> +<path style=" stroke:none;fill-rule:evenodd;fill:rgb(36.84082%,50.67749%,70.979309%);fill-opacity:1;" d="M 382.148438 113 C 382.148438 112.164062 381.816406 111.363281 381.226562 110.773438 C 380.636719 110.183594 379.835938 109.851562 379 109.851562 C 378.164062 109.851562 377.363281 110.183594 376.773438 110.773438 C 376.183594 111.363281 375.851562 112.164062 375.851562 113 C 375.851562 113.835938 376.183594 114.636719 376.773438 115.226562 C 377.363281 115.816406 378.164062 116.148438 379 116.148438 C 379.835938 116.148438 380.636719 115.816406 381.226562 115.226562 C 381.816406 114.636719 382.148438 113.835938 382.148438 113 Z "/> +<g style="fill:rgb(0%,0%,0%);fill-opacity:1;"> + <use xlink:href="#glyph4-1" x="391" y="117.28418"/> + <use xlink:href="#glyph4-2" x="399.670898" y="117.28418"/> + <use xlink:href="#glyph4-2" x="406.901367" y="117.28418"/> + <use xlink:href="#glyph4-3" x="414.131836" y="117.28418"/> + <use xlink:href="#glyph4-4" x="420.631836" y="117.28418"/> +</g> +<g style="fill:rgb(0%,0%,0%);fill-opacity:1;"> + <use xlink:href="#glyph4-5" x="424" y="117.28418"/> +</g> +<g style="fill:rgb(0%,0%,0%);fill-opacity:1;"> + <use xlink:href="#glyph4-6" x="428" y="117.28418"/> + <use xlink:href="#glyph4-7" x="436.670898" y="117.28418"/> + <use xlink:href="#glyph4-4" x="443.170898" y="117.28418"/> + <use xlink:href="#glyph4-8" x="446.783203" y="117.28418"/> + <use xlink:href="#glyph4-2" x="454.013672" y="117.28418"/> + <use xlink:href="#glyph4-9" x="461.244141" y="117.28418"/> +</g> +<path style=" stroke:none;fill-rule:evenodd;fill:rgb(88.070679%,61.103821%,14.204407%);fill-opacity:1;" d="M 382.148438 136 C 382.148438 135.164062 381.816406 134.363281 381.226562 133.773438 C 380.636719 133.183594 379.835938 132.851562 379 132.851562 C 378.164062 132.851562 377.363281 133.183594 376.773438 133.773438 C 376.183594 134.363281 375.851562 135.164062 375.851562 136 C 375.851562 136.835938 376.183594 137.636719 376.773438 138.226562 C 377.363281 138.816406 378.164062 139.148438 379 139.148438 C 379.835938 139.148438 380.636719 138.816406 381.226562 138.226562 C 381.816406 137.636719 382.148438 136.835938 382.148438 136 Z "/> +<g style="fill:rgb(0%,0%,0%);fill-opacity:1;"> + <use xlink:href="#glyph4-10" x="391" y="140.28418"/> + <use xlink:href="#glyph4-7" x="398.230469" y="140.28418"/> + <use xlink:href="#glyph4-11" x="404.730469" y="140.28418"/> + <use xlink:href="#glyph4-12" x="411.960938" y="140.28418"/> + <use xlink:href="#glyph4-9" x="414.849609" y="140.28418"/> + <use xlink:href="#glyph4-13" x="422.080078" y="140.28418"/> + <use xlink:href="#glyph4-14" x="429.310547" y="140.28418"/> + <use xlink:href="#glyph4-14" x="436.541016" y="140.28418"/> +</g> +</g> +</svg> diff --git a/stormpy/resources/pybind11/docs/reference.rst b/stormpy/resources/pybind11/docs/reference.rst new file mode 100644 index 000000000..4df4344a8 --- /dev/null +++ b/stormpy/resources/pybind11/docs/reference.rst @@ -0,0 +1,246 @@ +.. _reference: + +.. warning:: + + Please be advised that the reference documentation discussing pybind11 + internals is currently incomplete. Please refer to the previous sections + and the pybind11 header files for the nitty gritty details. + +Reference +######### + +Macros +====== + +.. function:: PYBIND11_PLUGIN(const char *name) + + This macro creates the entry point that will be invoked when the Python + interpreter imports a plugin library. Please create a + :class:`module` in the function body and return the pointer to its + underlying Python object at the end. + + .. code-block:: cpp + + PYBIND11_PLUGIN(example) { + pybind11::module m("example", "pybind11 example plugin"); + /// Set up bindings here + return m.ptr(); + } + +.. _core_types: + +Convenience classes for arbitrary Python types +============================================== + +Without reference counting +-------------------------- + +.. class:: handle + + The :class:`handle` class is a thin wrapper around an arbitrary Python + object (i.e. a ``PyObject *`` in Python's C API). It does not perform any + automatic reference counting and merely provides a basic C++ interface to + various Python API functions. + +.. seealso:: + + The :class:`object` class inherits from :class:`handle` and adds automatic + reference counting features. + +.. function:: handle::handle() + + The default constructor creates a handle with a ``nullptr``-valued pointer. + +.. function:: handle::handle(const handle&) + + Copy constructor + +.. function:: handle::handle(PyObject *) + + Creates a :class:`handle` from the given raw Python object pointer. + +.. function:: PyObject * handle::ptr() const + + Return the ``PyObject *`` underlying a :class:`handle`. + +.. function:: const handle& handle::inc_ref() const + + Manually increase the reference count of the Python object. Usually, it is + preferable to use the :class:`object` class which derives from + :class:`handle` and calls this function automatically. Returns a reference + to itself. + +.. function:: const handle& handle::dec_ref() const + + Manually decrease the reference count of the Python object. Usually, it is + preferable to use the :class:`object` class which derives from + :class:`handle` and calls this function automatically. Returns a reference + to itself. + +.. function:: void handle::ref_count() const + + Return the object's current reference count + +.. function:: handle handle::get_type() const + + Return a handle to the Python type object underlying the instance + +.. function detail::accessor handle::operator[](handle key) const + + Return an internal functor to invoke the object's sequence protocol. + Casting the returned ``detail::accessor`` instance to a :class:`handle` or + :class:`object` subclass causes a corresponding call to ``__getitem__``. + Assigning a :class:`handle` or :class:`object` subclass causes a call to + ``__setitem__``. + +.. function detail::accessor handle::operator[](const char *key) const + + See the above function (the only difference is that they key is provided as + a string literal). + +.. function detail::accessor handle::attr(handle key) const + + Return an internal functor to access the object's attributes. + Casting the returned ``detail::accessor`` instance to a :class:`handle` or + :class:`object` subclass causes a corresponding call to ``__getattr``. + Assigning a :class:`handle` or :class:`object` subclass causes a call to + ``__setattr``. + +.. function detail::accessor handle::attr(const char *key) const + + See the above function (the only difference is that they key is provided as + a string literal). + +.. function operator handle::bool() const + + Return ``true`` when the :class:`handle` wraps a valid Python object. + +.. function str handle::str() const + + Return a string representation of the object. This is analogous to + the ``str()`` function in Python. + +.. function:: template <typename T> T handle::cast() const + + Attempt to cast the Python object into the given C++ type. A + :class:`cast_error` will be throw upon failure. + +.. function:: template <typename ... Args> object handle::call(Args&&... args) const + + Assuming the Python object is a function or implements the ``__call__`` + protocol, ``call()`` invokes the underlying function, passing an arbitrary + set of parameters. The result is returned as a :class:`object` and may need + to be converted back into a Python object using :func:`handle::cast`. + + When some of the arguments cannot be converted to Python objects, the + function will throw a :class:`cast_error` exception. When the Python + function call fails, a :class:`error_already_set` exception is thrown. + +With reference counting +----------------------- + +.. class:: object : public handle + + Like :class:`handle`, the object class is a thin wrapper around an + arbitrary Python object (i.e. a ``PyObject *`` in Python's C API). In + contrast to :class:`handle`, it optionally increases the object's reference + count upon construction, and it *always* decreases the reference count when + the :class:`object` instance goes out of scope and is destructed. When + using :class:`object` instances consistently, it is much easier to get + reference counting right at the first attempt. + +.. function:: object::object(const object &o) + + Copy constructor; always increases the reference count + +.. function:: object::object(const handle &h, bool borrowed) + + Creates a :class:`object` from the given :class:`handle`. The reference + count is only increased if the ``borrowed`` parameter is set to ``true``. + +.. function:: object::object(PyObject *ptr, bool borrowed) + + Creates a :class:`object` from the given raw Python object pointer. The + reference count is only increased if the ``borrowed`` parameter is set to + ``true``. + +.. function:: object::object(object &&other) + + Move constructor; steals the object from ``other`` and preserves its + reference count. + +.. function:: handle object::release() + + Resets the internal pointer to ``nullptr`` without without decreasing the + object's reference count. The function returns a raw handle to the original + Python object. + +.. function:: object::~object() + + Destructor, which automatically calls :func:`handle::dec_ref()`. + +Convenience classes for specific Python types +============================================= + + +.. class:: module : public object + +.. function:: module::module(const char *name, const char *doc = nullptr) + + Create a new top-level Python module with the given name and docstring + +.. function:: module module::def_submodule(const char *name, const char *doc = nullptr) + + Create and return a new Python submodule with the given name and docstring. + This also works recursively, i.e. + + .. code-block:: cpp + + pybind11::module m("example", "pybind11 example plugin"); + pybind11::module m2 = m.def_submodule("sub", "A submodule of 'example'"); + pybind11::module m3 = m2.def_submodule("subsub", "A submodule of 'example.sub'"); + +.. cpp:function:: template <typename Func, typename ... Extra> module& module::def(const char *name, Func && f, Extra && ... extra) + + Create Python binding for a new function within the module scope. ``Func`` + can be a plain C++ function, a function pointer, or a lambda function. For + details on the ``Extra&& ... extra`` argument, see section :ref:`extras`. + +.. _extras: + +Passing extra arguments to the def function +=========================================== + +.. class:: arg + +.. function:: arg::arg(const char *name) + +.. function:: template <typename T> arg_t<T> arg::operator=(const T &value) + +.. class:: template <typename T> arg_t<T> : public arg + + Represents a named argument with a default value + +.. class:: sibling + + Used to specify a handle to an existing sibling function; used internally + to implement function overloading in :func:`module::def` and + :func:`class_::def`. + +.. function:: sibling::sibling(handle handle) + +.. class doc + + This is class is internally used by pybind11. + +.. function:: doc::doc(const char *value) + + Create a new docstring with the specified value + +.. class name + + This is class is internally used by pybind11. + +.. function:: name::name(const char *value) + + Used to specify the function name diff --git a/stormpy/resources/pybind11/docs/release.rst b/stormpy/resources/pybind11/docs/release.rst new file mode 100644 index 000000000..591158e95 --- /dev/null +++ b/stormpy/resources/pybind11/docs/release.rst @@ -0,0 +1,21 @@ +To release a new version of pybind11: + +- Update the version number and push to pypi + - Update ``pybind11/_version.py`` (set release version, remove 'dev') + - ``git add`` and ``git commit``. + - ``python setup.py sdist upload``. + - ``python setup.py bdist_wheel upload``. + - Tag release date in ``doc/changelog.rst``. +- Tag the commit and push to anaconda.org + - ``git tag -a X.X -m '[Release comment]'``. + - ``conda-build conda.recipe --output`` + This should ouput the path of the generated tar.bz2 for the package + - ``conda-convert --platform all [path/to/tar.bz2] -o .`` + - ``for i in *-32/* *-64/*; do anaconda upload -u pybind $i; done`` +- Get back to work + - Update ``_version.py`` (add 'dev' and increment minor). + - Update version macros in ``include/pybind11/common.h`` + - ``git add`` and ``git commit``. ``git push``. ``git push --tags``. + +The remote for the last ``git push --tags`` should be the main repository for +pybind11. diff --git a/stormpy/resources/pybind11/example/example.cpp b/stormpy/resources/pybind11/example/example.cpp new file mode 100644 index 000000000..ba0ff2812 --- /dev/null +++ b/stormpy/resources/pybind11/example/example.cpp @@ -0,0 +1,52 @@ +/* + example/example.cpp -- pybind example plugin + + Copyright (c) 2015 Wenzel Jakob <wenzel@inf.ethz.ch> + + All rights reserved. Use of this source code is governed by a + BSD-style license that can be found in the LICENSE file. +*/ + +#include "example.h" + +void init_ex1(py::module &); +void init_ex2(py::module &); +void init_ex3(py::module &); +void init_ex4(py::module &); +void init_ex5(py::module &); +void init_ex6(py::module &); +void init_ex7(py::module &); +void init_ex8(py::module &); +void init_ex9(py::module &); +void init_ex10(py::module &); +void init_ex11(py::module &); +void init_ex12(py::module &); +void init_ex13(py::module &); +void init_ex14(py::module &); +void init_ex15(py::module &); +void init_ex16(py::module &); +void init_issues(py::module &); + +PYBIND11_PLUGIN(example) { + py::module m("example", "pybind example plugin"); + + init_ex1(m); + init_ex2(m); + init_ex3(m); + init_ex4(m); + init_ex5(m); + init_ex6(m); + init_ex7(m); + init_ex8(m); + init_ex9(m); + init_ex10(m); + init_ex11(m); + init_ex12(m); + init_ex13(m); + init_ex14(m); + init_ex15(m); + init_ex16(m); + init_issues(m); + + return m.ptr(); +} diff --git a/stormpy/resources/pybind11/example/example.h b/stormpy/resources/pybind11/example/example.h new file mode 100644 index 000000000..ab8fff796 --- /dev/null +++ b/stormpy/resources/pybind11/example/example.h @@ -0,0 +1,7 @@ +#include <pybind11/pybind11.h> +#include <iostream> + +using std::cout; +using std::endl; + +namespace py = pybind11; diff --git a/stormpy/resources/pybind11/example/example1.cpp b/stormpy/resources/pybind11/example/example1.cpp new file mode 100644 index 000000000..2a0038d82 --- /dev/null +++ b/stormpy/resources/pybind11/example/example1.cpp @@ -0,0 +1,92 @@ +/* + example/example1.cpp -- constructors, deconstructors, attribute access, + __str__, argument and return value conventions + + Copyright (c) 2015 Wenzel Jakob <wenzel@inf.ethz.ch> + + All rights reserved. Use of this source code is governed by a + BSD-style license that can be found in the LICENSE file. +*/ + +#include "example.h" + +class Example1 { +public: + Example1() { + cout << "Called Example1 default constructor.." << endl; + } + Example1(int value) : value(value) { + cout << "Called Example1 constructor with value " << value << ".." << endl; + } + Example1(const Example1 &e) : value(e.value) { + cout << "Called Example1 copy constructor with value " << value << ".." << endl; + } + Example1(Example1 &&e) : value(e.value) { + cout << "Called Example1 move constructor with value " << value << ".." << endl; + e.value = 0; + } + ~Example1() { + cout << "Called Example1 destructor (" << value << ")" << endl; + } + std::string toString() { + return "Example1[value=" + std::to_string(value) + "]"; + } + + void operator=(const Example1 &e) { cout << "Assignment operator" << endl; value = e.value; } + void operator=(Example1 &&e) { cout << "Move assignment operator" << endl; value = e.value; e.value = 0;} + + void add1(Example1 other) { value += other.value; } // passing by value + void add2(Example1 &other) { value += other.value; } // passing by reference + void add3(const Example1 &other) { value += other.value; } // passing by const reference + void add4(Example1 *other) { value += other->value; } // passing by pointer + void add5(const Example1 *other) { value += other->value; } // passing by const pointer + + void add6(int other) { value += other; } // passing by value + void add7(int &other) { value += other; } // passing by reference + void add8(const int &other) { value += other; } // passing by const reference + void add9(int *other) { value += *other; } // passing by pointer + void add10(const int *other) { value += *other; } // passing by const pointer + + Example1 self1() { return *this; } // return by value + Example1 &self2() { return *this; } // return by reference + const Example1 &self3() { return *this; } // return by const reference + Example1 *self4() { return this; } // return by pointer + const Example1 *self5() { return this; } // return by const pointer + + int internal1() { return value; } // return by value + int &internal2() { return value; } // return by reference + const int &internal3() { return value; } // return by const reference + int *internal4() { return &value; } // return by pointer + const int *internal5() { return &value; } // return by const pointer + + int value = 0; +}; + +void init_ex1(py::module &m) { + py::class_<Example1>(m, "Example1") + .def(py::init<>()) + .def(py::init<int>()) + .def(py::init<const Example1&>()) + .def("add1", &Example1::add1) + .def("add2", &Example1::add2) + .def("add3", &Example1::add3) + .def("add4", &Example1::add4) + .def("add5", &Example1::add5) + .def("add6", &Example1::add6) + .def("add7", &Example1::add7) + .def("add8", &Example1::add8) + .def("add9", &Example1::add9) + .def("add10", &Example1::add10) + .def("self1", &Example1::self1) + .def("self2", &Example1::self2) + .def("self3", &Example1::self3) + .def("self4", &Example1::self4) + .def("self5", &Example1::self5) + .def("internal1", &Example1::internal1) + .def("internal2", &Example1::internal2) + .def("internal3", &Example1::internal3) + .def("internal4", &Example1::internal4) + .def("internal5", &Example1::internal5) + .def("__str__", &Example1::toString) + .def_readwrite("value", &Example1::value); +} diff --git a/stormpy/resources/pybind11/example/example1.py b/stormpy/resources/pybind11/example/example1.py new file mode 100755 index 000000000..f89b662d8 --- /dev/null +++ b/stormpy/resources/pybind11/example/example1.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python +from __future__ import print_function +import sys +sys.path.append('.') + +from example import Example1 + +instance1 = Example1() +instance2 = Example1(32) +instance1.add1(instance2) +instance1.add2(instance2) +instance1.add3(instance2) +instance1.add4(instance2) +instance1.add5(instance2) +instance1.add6(32) +instance1.add7(32) +instance1.add8(32) +instance1.add9(32) +instance1.add10(32) + +print("Instance 1: " + str(instance1)) +print("Instance 2: " + str(instance2)) + +print(instance1.self1()) +print(instance1.self2()) +print(instance1.self3()) +print(instance1.self4()) +print(instance1.self5()) +print(instance1.internal1()) +print(instance1.internal2()) +print(instance1.internal3()) +print(instance1.internal4()) +print(instance1.internal5()) + +print("Instance 1, direct access = %i" % instance1.value) +instance1.value = 100 +print("Instance 1: " + str(instance1)) diff --git a/stormpy/resources/pybind11/example/example1.ref b/stormpy/resources/pybind11/example/example1.ref new file mode 100644 index 000000000..37c7fef9a --- /dev/null +++ b/stormpy/resources/pybind11/example/example1.ref @@ -0,0 +1,26 @@ +Called Example1 default constructor.. +Called Example1 constructor with value 32.. +Called Example1 copy constructor with value 32.. +Called Example1 copy constructor with value 32.. +Called Example1 destructor (32) +Called Example1 destructor (32) +Instance 1: Example1[value=320] +Instance 2: Example1[value=32] +Called Example1 copy constructor with value 320.. +Called Example1 copy constructor with value 320.. +Called Example1 destructor (320) +Example1[value=320] +Called Example1 destructor (320) +Example1[value=320] +Example1[value=320] +Example1[value=320] +Example1[value=320] +320 +320 +320 +320 +320 +Instance 1, direct access = 320 +Instance 1: Example1[value=100] +Called Example1 destructor (32) +Called Example1 destructor (100) diff --git a/stormpy/resources/pybind11/example/example10.cpp b/stormpy/resources/pybind11/example/example10.cpp new file mode 100644 index 000000000..1a377e569 --- /dev/null +++ b/stormpy/resources/pybind11/example/example10.cpp @@ -0,0 +1,36 @@ +/* + example/example10.cpp -- auto-vectorize functions over NumPy array + arguments + + Copyright (c) 2015 Wenzel Jakob <wenzel@inf.ethz.ch> + + All rights reserved. Use of this source code is governed by a + BSD-style license that can be found in the LICENSE file. +*/ + +#include "example.h" +#include <pybind11/numpy.h> + +double my_func(int x, float y, double z) { + std::cout << "my_func(x:int=" << x << ", y:float=" << y << ", z:float=" << z << ")" << std::endl; + return x*y*z; +} + +std::complex<double> my_func3(std::complex<double> c) { + return c * std::complex<double>(2.f); +} + +void init_ex10(py::module &m) { + // Vectorize all arguments of a function (though non-vector arguments are also allowed) + m.def("vectorized_func", py::vectorize(my_func)); + + // Vectorize a lambda function with a capture object (e.g. to exclude some arguments from the vectorization) + m.def("vectorized_func2", + [](py::array_t<int> x, py::array_t<float> y, float z) { + return py::vectorize([z](int x, float y) { return my_func(x, y, z); })(x, y); + } + ); + + // Vectorize a complex-valued function + m.def("vectorized_func3", py::vectorize(my_func3)); +} diff --git a/stormpy/resources/pybind11/example/example10.py b/stormpy/resources/pybind11/example/example10.py new file mode 100755 index 000000000..0d49fcaa7 --- /dev/null +++ b/stormpy/resources/pybind11/example/example10.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python +from __future__ import print_function +import sys +sys.path.append('.') + +import example +try: + import numpy as np +except ImportError: + print('NumPy missing') + exit(0) + +from example import vectorized_func +from example import vectorized_func2 +from example import vectorized_func3 + +print(vectorized_func3(np.array(3+7j))) + +for f in [vectorized_func, vectorized_func2]: + print(f(1, 2, 3)) + print(f(np.array(1), np.array(2), 3)) + print(f(np.array([1, 3]), np.array([2, 4]), 3)) + print(f(np.array([[1, 3, 5], [7, 9, 11]]), np.array([[2, 4, 6], [8, 10, 12]]), 3)) + print(np.array([[1, 3, 5], [7, 9, 11]])* np.array([[2, 4, 6], [8, 10, 12]])*3) + print(f(np.array([[1, 2, 3], [4, 5, 6]]), np.array([2, 3, 4]), 2)) + print(np.array([[1, 2, 3], [4, 5, 6]])* np.array([2, 3, 4])* 2) + print(f(np.array([[1, 2, 3], [4, 5, 6]]), np.array([[2], [3]]), 2)) + print(np.array([[1, 2, 3], [4, 5, 6]])* np.array([[2], [3]])* 2) + diff --git a/stormpy/resources/pybind11/example/example10.ref b/stormpy/resources/pybind11/example/example10.ref new file mode 100644 index 000000000..9d48d7cfd --- /dev/null +++ b/stormpy/resources/pybind11/example/example10.ref @@ -0,0 +1,75 @@ +(6+14j) +my_func(x:int=1, y:float=2, z:float=3) +6.0 +my_func(x:int=1, y:float=2, z:float=3) +6.0 +my_func(x:int=1, y:float=2, z:float=3) +my_func(x:int=3, y:float=4, z:float=3) +[ 6. 36.] +my_func(x:int=1, y:float=2, z:float=3) +my_func(x:int=3, y:float=4, z:float=3) +my_func(x:int=5, y:float=6, z:float=3) +my_func(x:int=7, y:float=8, z:float=3) +my_func(x:int=9, y:float=10, z:float=3) +my_func(x:int=11, y:float=12, z:float=3) +[[ 6. 36. 90.] + [ 168. 270. 396.]] +[[ 6 36 90] + [168 270 396]] +my_func(x:int=1, y:float=2, z:float=2) +my_func(x:int=2, y:float=3, z:float=2) +my_func(x:int=3, y:float=4, z:float=2) +my_func(x:int=4, y:float=2, z:float=2) +my_func(x:int=5, y:float=3, z:float=2) +my_func(x:int=6, y:float=4, z:float=2) +[[ 4. 12. 24.] + [ 16. 30. 48.]] +[[ 4 12 24] + [16 30 48]] +my_func(x:int=1, y:float=2, z:float=2) +my_func(x:int=2, y:float=2, z:float=2) +my_func(x:int=3, y:float=2, z:float=2) +my_func(x:int=4, y:float=3, z:float=2) +my_func(x:int=5, y:float=3, z:float=2) +my_func(x:int=6, y:float=3, z:float=2) +[[ 4. 8. 12.] + [ 24. 30. 36.]] +[[ 4 8 12] + [24 30 36]] +my_func(x:int=1, y:float=2, z:float=3) +6.0 +my_func(x:int=1, y:float=2, z:float=3) +6.0 +my_func(x:int=1, y:float=2, z:float=3) +my_func(x:int=3, y:float=4, z:float=3) +[ 6. 36.] +my_func(x:int=1, y:float=2, z:float=3) +my_func(x:int=3, y:float=4, z:float=3) +my_func(x:int=5, y:float=6, z:float=3) +my_func(x:int=7, y:float=8, z:float=3) +my_func(x:int=9, y:float=10, z:float=3) +my_func(x:int=11, y:float=12, z:float=3) +[[ 6. 36. 90.] + [ 168. 270. 396.]] +[[ 6 36 90] + [168 270 396]] +my_func(x:int=1, y:float=2, z:float=2) +my_func(x:int=2, y:float=3, z:float=2) +my_func(x:int=3, y:float=4, z:float=2) +my_func(x:int=4, y:float=2, z:float=2) +my_func(x:int=5, y:float=3, z:float=2) +my_func(x:int=6, y:float=4, z:float=2) +[[ 4. 12. 24.] + [ 16. 30. 48.]] +[[ 4 12 24] + [16 30 48]] +my_func(x:int=1, y:float=2, z:float=2) +my_func(x:int=2, y:float=2, z:float=2) +my_func(x:int=3, y:float=2, z:float=2) +my_func(x:int=4, y:float=3, z:float=2) +my_func(x:int=5, y:float=3, z:float=2) +my_func(x:int=6, y:float=3, z:float=2) +[[ 4. 8. 12.] + [ 24. 30. 36.]] +[[ 4 8 12] + [24 30 36]] diff --git a/stormpy/resources/pybind11/example/example11.cpp b/stormpy/resources/pybind11/example/example11.cpp new file mode 100644 index 000000000..e7069def2 --- /dev/null +++ b/stormpy/resources/pybind11/example/example11.cpp @@ -0,0 +1,33 @@ +/* + example/example11.cpp -- keyword arguments and default values + + Copyright (c) 2015 Wenzel Jakob <wenzel@inf.ethz.ch> + + All rights reserved. Use of this source code is governed by a + BSD-style license that can be found in the LICENSE file. +*/ + +#include "example.h" +#include <pybind11/stl.h> + +void kw_func(int x, int y) { std::cout << "kw_func(x=" << x << ", y=" << y << ")" << std::endl; } + +void kw_func4(const std::vector<int> &entries) { + std::cout << "kw_func4: "; + for (int i : entries) + std::cout << i << " "; + std::cout << endl; +} + +void init_ex11(py::module &m) { + m.def("kw_func", &kw_func, py::arg("x"), py::arg("y")); + m.def("kw_func2", &kw_func, py::arg("x") = 100, py::arg("y") = 200); + m.def("kw_func3", [](const char *) { }, py::arg("data") = std::string("Hello world!")); + + /* A fancier default argument */ + std::vector<int> list; + list.push_back(13); + list.push_back(17); + + m.def("kw_func4", &kw_func4, py::arg("myList") = list); +} diff --git a/stormpy/resources/pybind11/example/example11.py b/stormpy/resources/pybind11/example/example11.py new file mode 100755 index 000000000..04baa7bc9 --- /dev/null +++ b/stormpy/resources/pybind11/example/example11.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python +from __future__ import print_function +import sys +import pydoc + +sys.path.append('.') + +from example import kw_func, kw_func2, kw_func3, kw_func4 + +print(pydoc.render_doc(kw_func, "Help on %s")) +print(pydoc.render_doc(kw_func2, "Help on %s")) +print(pydoc.render_doc(kw_func3, "Help on %s")) +print(pydoc.render_doc(kw_func4, "Help on %s")) + +kw_func(5, 10) +kw_func(5, y=10) +kw_func(y=10, x=5) + +kw_func2() + +kw_func2(5) +kw_func2(x=5) + +kw_func2(y=10) + +kw_func2(5, 10) +kw_func2(x=5, y=10) + +try: + kw_func2(x=5, y=10, z=12) +except Exception as e: + print("Caught expected exception: " + str(e)) + +kw_func4() +kw_func4(myList = [1, 2, 3]) diff --git a/stormpy/resources/pybind11/example/example11.ref b/stormpy/resources/pybind11/example/example11.ref new file mode 100644 index 000000000..54e4fef31 --- /dev/null +++ b/stormpy/resources/pybind11/example/example11.ref @@ -0,0 +1,34 @@ +Help on built-in function kw_func in module example + +kkww__ffuunncc(...) + kw_func(x : int, y : int) -> NoneType + +Help on built-in function kw_func2 in module example + +kkww__ffuunncc22(...) + kw_func2(x : int = 100L, y : int = 200L) -> NoneType + +Help on built-in function kw_func3 in module example + +kkww__ffuunncc33(...) + kw_func3(data : unicode = u'Hello world!') -> NoneType + +Help on built-in function kw_func4 in module example + +kkww__ffuunncc44(...) + kw_func4(myList : list<int> = [13L, 17L]) -> NoneType + +kw_func(x=5, y=10) +kw_func(x=5, y=10) +kw_func(x=5, y=10) +kw_func(x=100, y=200) +kw_func(x=5, y=200) +kw_func(x=5, y=200) +kw_func(x=100, y=10) +kw_func(x=5, y=10) +kw_func(x=5, y=10) +Caught expected exception: Incompatible function arguments. The following argument types are supported: + 1. (x : int = 100L, y : int = 200L) -> NoneType + +kw_func4: 13 17 +kw_func4: 1 2 3 diff --git a/stormpy/resources/pybind11/example/example12.cpp b/stormpy/resources/pybind11/example/example12.cpp new file mode 100644 index 000000000..ab1b48294 --- /dev/null +++ b/stormpy/resources/pybind11/example/example12.cpp @@ -0,0 +1,98 @@ +/* + example/example12.cpp -- overriding virtual functions from Python + + Copyright (c) 2015 Wenzel Jakob <wenzel@inf.ethz.ch> + + All rights reserved. Use of this source code is governed by a + BSD-style license that can be found in the LICENSE file. +*/ + +#include "example.h" +#include <pybind11/functional.h> + +/* This is an example class that we'll want to be able to extend from Python */ +class Example12 { +public: + Example12(int state) : state(state) { + cout << "Constructing Example12.." << endl; + } + + ~Example12() { + cout << "Destructing Example12.." << endl; + } + + virtual int run(int value) { + std::cout << "Original implementation of Example12::run(state=" << state + << ", value=" << value << ")" << std::endl; + return state + value; + } + + virtual bool run_bool() = 0; + virtual void pure_virtual() = 0; +private: + int state; +}; + +/* This is a wrapper class that must be generated */ +class PyExample12 : public Example12 { +public: + using Example12::Example12; /* Inherit constructors */ + + virtual int run(int value) { + /* Generate wrapping code that enables native function overloading */ + PYBIND11_OVERLOAD( + int, /* Return type */ + Example12, /* Parent class */ + run, /* Name of function */ + value /* Argument(s) */ + ); + } + + virtual bool run_bool() { + PYBIND11_OVERLOAD_PURE( + bool, + Example12, + run_bool + ); + throw std::runtime_error("this will never be reached"); + } + + virtual void pure_virtual() { + PYBIND11_OVERLOAD_PURE( + void, /* Return type */ + Example12, /* Parent class */ + pure_virtual /* Name of function */ + /* This function has no arguments */ + ); + } +}; + +int runExample12(Example12 *ex, int value) { + return ex->run(value); +} + +bool runExample12Bool(Example12* ex) { + return ex->run_bool(); +} + +void runExample12Virtual(Example12 *ex) { + ex->pure_virtual(); +} + +void init_ex12(py::module &m) { + /* Important: use the wrapper type as a template + argument to class_<>, but use the original name + to denote the type */ + py::class_<PyExample12>(m, "Example12") + /* Declare that 'PyExample12' is really an alias for the original type 'Example12' */ + .alias<Example12>() + .def(py::init<int>()) + /* Reference original class in function definitions */ + .def("run", &Example12::run) + .def("run_bool", &Example12::run_bool) + .def("pure_virtual", &Example12::pure_virtual); + + m.def("runExample12", &runExample12); + m.def("runExample12Bool", &runExample12Bool); + m.def("runExample12Virtual", &runExample12Virtual); +} diff --git a/stormpy/resources/pybind11/example/example12.py b/stormpy/resources/pybind11/example/example12.py new file mode 100644 index 000000000..eb175239f --- /dev/null +++ b/stormpy/resources/pybind11/example/example12.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python +from __future__ import print_function +import sys +sys.path.append('.') + +from example import Example12, runExample12, runExample12Virtual, runExample12Bool + + +class ExtendedExample12(Example12): + def __init__(self, state): + super(ExtendedExample12, self).__init__(state + 1) + self.data = "Hello world" + + def run(self, value): + print('ExtendedExample12::run(%i), calling parent..' % value) + return super(ExtendedExample12, self).run(value + 1) + + def run_bool(self): + print('ExtendedExample12::run_bool()') + return False + + def pure_virtual(self): + print('ExtendedExample12::pure_virtual(): %s' % self.data) + + +ex12 = Example12(10) +print(runExample12(ex12, 20)) +try: + runExample12Virtual(ex12) +except Exception as e: + print("Caught expected exception: " + str(e)) + +ex12p = ExtendedExample12(10) +print(runExample12(ex12p, 20)) +print(runExample12Bool(ex12p)) +runExample12Virtual(ex12p) diff --git a/stormpy/resources/pybind11/example/example12.ref b/stormpy/resources/pybind11/example/example12.ref new file mode 100644 index 000000000..2274cddd2 --- /dev/null +++ b/stormpy/resources/pybind11/example/example12.ref @@ -0,0 +1,13 @@ +Constructing Example12.. +Original implementation of Example12::run(state=10, value=20) +30 +Caught expected exception: Tried to call pure virtual function "pure_virtual" +Constructing Example12.. +ExtendedExample12::run(20), calling parent.. +Original implementation of Example12::run(state=11, value=21) +32 +ExtendedExample12::run_bool() +False +ExtendedExample12::pure_virtual(): Hello world +Destructing Example12.. +Destructing Example12.. diff --git a/stormpy/resources/pybind11/example/example13.cpp b/stormpy/resources/pybind11/example/example13.cpp new file mode 100644 index 000000000..782db3109 --- /dev/null +++ b/stormpy/resources/pybind11/example/example13.cpp @@ -0,0 +1,37 @@ +/* + example/example13.cpp -- keep_alive modifier (pybind11's version + of Boost.Python's with_custodian_and_ward / with_custodian_and_ward_postcall) + + Copyright (c) 2015 Wenzel Jakob <wenzel@inf.ethz.ch> + + All rights reserved. Use of this source code is governed by a + BSD-style license that can be found in the LICENSE file. +*/ + +#include "example.h" + +class Child { +public: + Child() { std::cout << "Allocating child." << std::endl; } + ~Child() { std::cout << "Releasing child." << std::endl; } +}; + +class Parent { +public: + Parent() { std::cout << "Allocating parent." << std::endl; } + ~Parent() { std::cout << "Releasing parent." << std::endl; } + void addChild(Child *) { } + Child *returnChild() { return new Child(); } +}; + +void init_ex13(py::module &m) { + py::class_<Parent>(m, "Parent") + .def(py::init<>()) + .def("addChild", &Parent::addChild) + .def("addChildKeepAlive", &Parent::addChild, py::keep_alive<1, 2>()) + .def("returnChild", &Parent::returnChild) + .def("returnChildKeepAlive", &Parent::returnChild, py::keep_alive<1, 0>()); + + py::class_<Child>(m, "Child") + .def(py::init<>()); +} diff --git a/stormpy/resources/pybind11/example/example13.py b/stormpy/resources/pybind11/example/example13.py new file mode 100644 index 000000000..ad0176ed4 --- /dev/null +++ b/stormpy/resources/pybind11/example/example13.py @@ -0,0 +1,46 @@ +from __future__ import print_function +import sys +import gc +sys.path.append('.') + +from example import Parent, Child + +if True: + p = Parent() + p.addChild(Child()) + gc.collect() + print(p) + p = None + +gc.collect() +print("") + +if True: + p = Parent() + p.returnChild() + gc.collect() + print(p) + p = None + +gc.collect() +print("") + +if True: + p = Parent() + p.addChildKeepAlive(Child()) + gc.collect() + print(p) + p = None +gc.collect() +print("") + +if True: + p = Parent() + p.returnChildKeepAlive() + gc.collect() + print(p) + p = None + +gc.collect() +print("") +print("Terminating..") diff --git a/stormpy/resources/pybind11/example/example13.ref b/stormpy/resources/pybind11/example/example13.ref new file mode 100644 index 000000000..7eb02c51f --- /dev/null +++ b/stormpy/resources/pybind11/example/example13.ref @@ -0,0 +1,25 @@ +Allocating parent. +Allocating child. +Releasing child. +<example.Parent object at 0x10eb726c0> +Releasing parent. + +Allocating parent. +Allocating child. +Releasing child. +<example.Parent object at 0x10eb726c0> +Releasing parent. + +Allocating parent. +Allocating child. +<example.Parent object at 0x10eb726c0> +Releasing parent. +Releasing child. + +Allocating parent. +Allocating child. +<example.Parent object at 0x10eb726c0> +Releasing parent. +Releasing child. + +Terminating.. diff --git a/stormpy/resources/pybind11/example/example14.cpp b/stormpy/resources/pybind11/example/example14.cpp new file mode 100644 index 000000000..abae02140 --- /dev/null +++ b/stormpy/resources/pybind11/example/example14.cpp @@ -0,0 +1,40 @@ +/* + example/example14.cpp -- opaque types, passing void pointers + + Copyright (c) 2015 Wenzel Jakob <wenzel@inf.ethz.ch> + + All rights reserved. Use of this source code is governed by a + BSD-style license that can be found in the LICENSE file. +*/ + +#include "example.h" +#include <pybind11/stl.h> +#include <vector> + +typedef std::vector<std::string> StringList; + +void init_ex14(py::module &m) { + py::class_<py::opaque<StringList>>(m, "StringList") + .def(py::init<>()) + .def("push_back", [](py::opaque<StringList> &l, const std::string &str) { l->push_back(str); }) + .def("pop_back", [](py::opaque<StringList> &l) { l->pop_back(); }) + .def("back", [](py::opaque<StringList> &l) { return l->back(); }); + + m.def("print_opaque_list", [](py::opaque<StringList> &_l) { + StringList &l = _l; + std::cout << "Opaque list: " << std::endl; + for (auto entry : l) + std::cout << " " << entry << std::endl; + }); + + m.def("return_void_ptr", []() { return (void *) 1234; }); + m.def("print_void_ptr", [](void *ptr) { std::cout << "Got void ptr : " << (uint64_t) ptr << std::endl; }); + m.def("return_null_str", []() { return (char *) nullptr; }); + m.def("print_null_str", [](char *ptr) { std::cout << "Got null str : " << (uint64_t) ptr << std::endl; }); + + m.def("return_unique_ptr", []() -> std::unique_ptr<StringList> { + StringList *result = new StringList(); + result->push_back("some value"); + return std::unique_ptr<StringList>(result); + }); +} diff --git a/stormpy/resources/pybind11/example/example14.py b/stormpy/resources/pybind11/example/example14.py new file mode 100644 index 000000000..82d14de84 --- /dev/null +++ b/stormpy/resources/pybind11/example/example14.py @@ -0,0 +1,24 @@ +from __future__ import print_function +import sys + +sys.path.append('.') + +from example import StringList, print_opaque_list +from example import return_void_ptr, print_void_ptr +from example import return_null_str, print_null_str +from example import return_unique_ptr + +l = StringList() +l.push_back("Element 1") +l.push_back("Element 2") +print_opaque_list(l) +print("Back element is %s" % l.back()) +l.pop_back() +print_opaque_list(l) + +print_void_ptr(return_void_ptr()) + +print(return_null_str()) +print_null_str(return_null_str()) + +print(return_unique_ptr()) diff --git a/stormpy/resources/pybind11/example/example14.ref b/stormpy/resources/pybind11/example/example14.ref new file mode 100644 index 000000000..b4768efe9 --- /dev/null +++ b/stormpy/resources/pybind11/example/example14.ref @@ -0,0 +1,10 @@ +Opaque list: + Element 1 + Element 2 +Back element is Element 2 +Opaque list: + Element 1 +Got void ptr : 1234 +None +Got null str : 0 +[u'some value'] diff --git a/stormpy/resources/pybind11/example/example15.cpp b/stormpy/resources/pybind11/example/example15.cpp new file mode 100644 index 000000000..bfc75268a --- /dev/null +++ b/stormpy/resources/pybind11/example/example15.cpp @@ -0,0 +1,51 @@ +/* + example/example15.cpp -- pickle support + + Copyright (c) 2015 Wenzel Jakob <wenzel@inf.ethz.ch> + + All rights reserved. Use of this source code is governed by a + BSD-style license that can be found in the LICENSE file. +*/ + +#include "example.h" + +class Pickleable { +public: + Pickleable(const std::string &value) : m_value(value) { } + const std::string &value() const { return m_value; } + + void setExtra1(int extra1) { m_extra1 = extra1; } + void setExtra2(int extra2) { m_extra2 = extra2; } + int extra1() const { return m_extra1; } + int extra2() const { return m_extra2; } +private: + std::string m_value; + int m_extra1 = 0; + int m_extra2 = 0; +}; + +void init_ex15(py::module &m) { + py::class_<Pickleable>(m, "Pickleable") + .def(py::init<std::string>()) + .def("value", &Pickleable::value) + .def("extra1", &Pickleable::extra1) + .def("extra2", &Pickleable::extra2) + .def("setExtra1", &Pickleable::setExtra1) + .def("setExtra2", &Pickleable::setExtra2) + // For details on the methods below, refer to + // http://docs.python.org/3/library/pickle.html#pickling-class-instances + .def("__getstate__", [](const Pickleable &p) { + /* Return a tuple that fully encodes the state of the object */ + return py::make_tuple(p.value(), p.extra1(), p.extra2()); + }) + .def("__setstate__", [](Pickleable &p, py::tuple t) { + if (t.size() != 3) + throw std::runtime_error("Invalid state!"); + /* Invoke the constructor (need to use in-place version) */ + new (&p) Pickleable(t[0].cast<std::string>()); + + /* Assign any additional state */ + p.setExtra1(t[1].cast<int>()); + p.setExtra2(t[2].cast<int>()); + }); +} diff --git a/stormpy/resources/pybind11/example/example15.py b/stormpy/resources/pybind11/example/example15.py new file mode 100644 index 000000000..9868b62c2 --- /dev/null +++ b/stormpy/resources/pybind11/example/example15.py @@ -0,0 +1,21 @@ +from __future__ import print_function +import sys + +sys.path.append('.') + +from example import Pickleable + +try: + import cPickle as pickle # Use cPickle on Python 2.7 +except ImportError: + import pickle + +p = Pickleable("test_value") +p.setExtra1(15) +p.setExtra2(48) + +data = pickle.dumps(p, -1) # -1 is important (use highest protocol version) +print("%s %i %i" % (p.value(), p.extra1(), p.extra2())) + +p2 = pickle.loads(data) +print("%s %i %i" % (p2.value(), p2.extra1(), p2.extra2())) diff --git a/stormpy/resources/pybind11/example/example15.ref b/stormpy/resources/pybind11/example/example15.ref new file mode 100644 index 000000000..d804973a1 --- /dev/null +++ b/stormpy/resources/pybind11/example/example15.ref @@ -0,0 +1,2 @@ +test_value 15 48 +test_value 15 48 diff --git a/stormpy/resources/pybind11/example/example16.cpp b/stormpy/resources/pybind11/example/example16.cpp new file mode 100644 index 000000000..350435f57 --- /dev/null +++ b/stormpy/resources/pybind11/example/example16.cpp @@ -0,0 +1,24 @@ +/* + example/example16.cpp -- automatic upcasting for polymorphic types + + Copyright (c) 2015 Wenzel Jakob <wenzel@inf.ethz.ch> + + All rights reserved. Use of this source code is governed by a + BSD-style license that can be found in the LICENSE file. +*/ + +#include "example.h" + +struct BaseClass { virtual ~BaseClass() {} }; +struct DerivedClass1 : BaseClass { }; +struct DerivedClass2 : BaseClass { }; + +void init_ex16(py::module &m) { + py::class_<BaseClass>(m, "BaseClass").def(py::init<>()); + py::class_<DerivedClass1>(m, "DerivedClass1").def(py::init<>()); + py::class_<DerivedClass2>(m, "DerivedClass2").def(py::init<>()); + + m.def("return_class_1", []() -> BaseClass* { return new DerivedClass1(); }); + m.def("return_class_2", []() -> BaseClass* { return new DerivedClass2(); }); + m.def("return_none", []() -> BaseClass* { return nullptr; }); +} diff --git a/stormpy/resources/pybind11/example/example16.py b/stormpy/resources/pybind11/example/example16.py new file mode 100644 index 000000000..b4bcb655d --- /dev/null +++ b/stormpy/resources/pybind11/example/example16.py @@ -0,0 +1,12 @@ +from __future__ import print_function +import sys + +sys.path.append('.') + +from example import return_class_1 +from example import return_class_2 +from example import return_none + +print(type(return_class_1()).__name__) +print(type(return_class_2()).__name__) +print(type(return_none()).__name__) diff --git a/stormpy/resources/pybind11/example/example16.ref b/stormpy/resources/pybind11/example/example16.ref new file mode 100644 index 000000000..96003367b --- /dev/null +++ b/stormpy/resources/pybind11/example/example16.ref @@ -0,0 +1,3 @@ +DerivedClass1 +DerivedClass2 +NoneType diff --git a/stormpy/resources/pybind11/example/example2.cpp b/stormpy/resources/pybind11/example/example2.cpp new file mode 100644 index 000000000..2d49286b1 --- /dev/null +++ b/stormpy/resources/pybind11/example/example2.cpp @@ -0,0 +1,172 @@ +/* + example/example2.cpp2 -- singleton design pattern, static functions and + variables, passing and interacting with Python types + + Copyright (c) 2015 Wenzel Jakob <wenzel@inf.ethz.ch> + + All rights reserved. Use of this source code is governed by a + BSD-style license that can be found in the LICENSE file. +*/ + +#include "example.h" +#include <pybind11/stl.h> + +#ifdef _WIN32 +# include <io.h> +# include <fcntl.h> +#endif + +class Example2 { +public: + static Example2 *new_instance() { + return new Example2(); + } + ~Example2() { + std::cout << "Destructing Example2" << std::endl; + } + + /* Create and return a Python dictionary */ + py::dict get_dict() { + py::dict dict; + dict[py::str("key")] = py::str("value"); + return dict; + } + + /* Create and return a Python set */ + py::set get_set() { + py::set set; + set.add(py::str("key1")); + set.add(py::str("key2")); + return set; + } + + /* Create and return a C++ dictionary */ + std::map<std::string, std::string> get_dict_2() { + std::map<std::string, std::string> result; + result["key"] = "value"; + return result; + } + + /* Create and return a C++ set */ + std::set<std::string> get_set_2() { + std::set<std::string> result; + result.insert("key1"); + result.insert("key2"); + return result; + } + + /* Create, manipulate, and return a Python list */ + py::list get_list() { + py::list list; + list.append(py::str("value")); + cout << "Entry at positon 0: " << py::object(list[0]) << endl; + list[0] = py::str("overwritten"); + return list; + } + + /* C++ STL data types are automatically casted */ + std::vector<std::wstring> get_list_2() { + std::vector<std::wstring> list; + list.push_back(L"value"); + return list; + } + + /* C++ STL data types are automatically casted */ + std::array<std::string, 2> get_array() { + return std::array<std::string, 2> {{ "array entry 1" , "array entry 2"}}; + } + + /* Easily iterate over a dictionary using a C++11 range-based for loop */ + void print_dict(py::dict dict) { + for (auto item : dict) + std::cout << "key: " << item.first << ", value=" << item.second << std::endl; + } + + /* Easily iterate over a set using a C++11 range-based for loop */ + void print_set(py::set set) { + for (auto item : set) + std::cout << "key: " << item << std::endl; + } + + /* Easily iterate over a list using a C++11 range-based for loop */ + void print_list(py::list list) { + int index = 0; + for (auto item : list) + std::cout << "list item " << index++ << ": " << item << std::endl; + } + + /* STL data types (such as maps) are automatically casted from Python */ + void print_dict_2(const std::map<std::string, std::string> &dict) { + for (auto item : dict) + std::cout << "key: " << item.first << ", value=" << item.second << std::endl; + } + + /* STL data types (such as sets) are automatically casted from Python */ + void print_set_2(const std::set<std::string> &set) { + for (auto item : set) + std::cout << "key: " << item << std::endl; + } + + /* STL data types (such as vectors) are automatically casted from Python */ + void print_list_2(std::vector<std::wstring> &list) { +#ifdef _WIN32 /* Can't easily mix cout and wcout on Windows */ + _setmode(_fileno(stdout), _O_TEXT); +#endif + int index = 0; + for (auto item : list) + std::wcout << L"list item " << index++ << L": " << item << std::endl; + } + + /* pybind automatically translates between C++11 and Python tuples */ + std::pair<std::string, bool> pair_passthrough(std::pair<bool, std::string> input) { + return std::make_pair(input.second, input.first); + } + + /* pybind automatically translates between C++11 and Python tuples */ + std::tuple<int, std::string, bool> tuple_passthrough(std::tuple<bool, std::string, int> input) { + return std::make_tuple(std::get<2>(input), std::get<1>(input), std::get<0>(input)); + } + + /* STL data types (such as arrays) are automatically casted from Python */ + void print_array(std::array<std::string, 2> &array) { + int index = 0; + for (auto item : array) + std::cout << "array item " << index++ << ": " << item << std::endl; + } + + void throw_exception() { + throw std::runtime_error("This exception was intentionally thrown."); + } + + static int value; + static const int value2; +}; + +int Example2::value = 0; +const int Example2::value2 = 5; + +void init_ex2(py::module &m) { + /* No constructor is explicitly defined below. An exception is raised when + trying to construct it directly from Python */ + py::class_<Example2>(m, "Example2", "Example 2 documentation") + .def("get_dict", &Example2::get_dict, "Return a Python dictionary") + .def("get_dict_2", &Example2::get_dict_2, "Return a C++ dictionary") + .def("get_list", &Example2::get_list, "Return a Python list") + .def("get_list_2", &Example2::get_list_2, "Return a C++ list") + .def("get_set", &Example2::get_set, "Return a Python set") + .def("get_set2", &Example2::get_set, "Return a C++ set") + .def("get_array", &Example2::get_array, "Return a C++ array") + .def("print_dict", &Example2::print_dict, "Print entries of a Python dictionary") + .def("print_dict_2", &Example2::print_dict_2, "Print entries of a C++ dictionary") + .def("print_set", &Example2::print_set, "Print entries of a Python set") + .def("print_set_2", &Example2::print_set_2, "Print entries of a C++ set") + .def("print_list", &Example2::print_list, "Print entries of a Python list") + .def("print_list_2", &Example2::print_list_2, "Print entries of a C++ list") + .def("print_array", &Example2::print_array, "Print entries of a C++ array") + .def("pair_passthrough", &Example2::pair_passthrough, "Return a pair in reversed order") + .def("tuple_passthrough", &Example2::tuple_passthrough, "Return a triple in reversed order") + .def("throw_exception", &Example2::throw_exception, "Throw an exception") + .def_static("new_instance", &Example2::new_instance, "Return an instance") + .def_readwrite_static("value", &Example2::value, "Static value member") + .def_readonly_static("value2", &Example2::value2, "Static value member (readonly)"); +} diff --git a/stormpy/resources/pybind11/example/example2.py b/stormpy/resources/pybind11/example/example2.py new file mode 100755 index 000000000..d335acc3d --- /dev/null +++ b/stormpy/resources/pybind11/example/example2.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python +from __future__ import print_function +import sys, pydoc +sys.path.append('.') + +import example +from example import Example2 + +Example2.value = 15 +print(Example2.value) +print(Example2.value2) + +try: + Example2() +except Exception as e: + print(e) + +try: + Example2.value2 = 15 +except Exception as e: + print(e) + +instance = Example2.new_instance() + +dict_result = instance.get_dict() +dict_result['key2'] = 'value2' +instance.print_dict(dict_result) + +dict_result = instance.get_dict_2() +dict_result['key2'] = 'value2' +instance.print_dict_2(dict_result) + +set_result = instance.get_set() +set_result.add('key3') +instance.print_set(set_result) + +set_result = instance.get_set2() +set_result.add('key3') +instance.print_set_2(set_result) + +list_result = instance.get_list() +list_result.append('value2') +instance.print_list(list_result) + +list_result = instance.get_list_2() +list_result.append('value2') +instance.print_list_2(list_result) + +array_result = instance.get_array() +print(array_result) +instance.print_array(array_result) + +try: + instance.throw_exception() +except Exception as e: + print(e) + +print(instance.pair_passthrough((True, "test"))) +print(instance.tuple_passthrough((True, "test", 5))) + +print(pydoc.render_doc(Example2, "Help on %s")) + +print("__name__(example) = %s" % example.__name__) +print("__name__(example.Example2) = %s" % Example2.__name__) +print("__module__(example.Example2) = %s" % Example2.__module__) +print("__name__(example.Example2.get_set) = %s" % Example2.get_set.__name__) +print("__module__(example.Example2.get_set) = %s" % Example2.get_set.__module__) diff --git a/stormpy/resources/pybind11/example/example2.ref b/stormpy/resources/pybind11/example/example2.ref new file mode 100644 index 000000000..fd6c83dda --- /dev/null +++ b/stormpy/resources/pybind11/example/example2.ref @@ -0,0 +1,137 @@ +15 +5 +example.Example2: No constructor defined! +can't set attribute +key: key2, value=value2 +key: key, value=value +key: key, value=value +key: key2, value=value2 +key: key3 +key: key2 +key: key1 +key: key1 +key: key2 +key: key3 +Entry at positon 0: value +list item 0: overwritten +list item 1: value2 +list item 0: value +list item 1: value2 +[u'array entry 1', u'array entry 2'] +array item 0: array entry 1 +array item 1: array entry 2 +This exception was intentionally thrown. +(u'test', True) +(5L, u'test', True) +Help on class Example2 in module example + +class EExxaammppllee22(__builtin__.object) + | Example 2 documentation + | + | Methods defined here: + | + | ____iinniitt____(...) + | x.__init__(...) initializes x; see help(type(x)) for signature + | + | ggeett__aarrrraayy(...) + | Signature : (example.Example2) -> list<unicode>[2] + | + | Return a C++ array + | + | ggeett__ddiicctt(...) + | Signature : (example.Example2) -> dict + | + | Return a Python dictionary + | + | ggeett__ddiicctt__22(...) + | Signature : (example.Example2) -> dict<unicode, unicode> + | + | Return a C++ dictionary + | + | ggeett__lliisstt(...) + | Signature : (example.Example2) -> list + | + | Return a Python list + | + | ggeett__lliisstt__22(...) + | Signature : (example.Example2) -> list<unicode> + | + | Return a C++ list + | + | ggeett__sseett(...) + | Signature : (example.Example2) -> set + | + | Return a Python set + | + | ggeett__sseett22(...) + | Signature : (example.Example2) -> set + | + | Return a C++ set + | + | ppaaiirr__ppaasssstthhrroouugghh(...) + | Signature : (example.Example2, (bool, unicode)) -> (unicode, bool) + | + | Return a pair in reversed order + | + | pprriinntt__aarrrraayy(...) + | Signature : (example.Example2, list<unicode>[2]) -> NoneType + | + | Print entries of a C++ array + | + | pprriinntt__ddiicctt(...) + | Signature : (example.Example2, dict) -> NoneType + | + | Print entries of a Python dictionary + | + | pprriinntt__ddiicctt__22(...) + | Signature : (example.Example2, dict<unicode, unicode>) -> NoneType + | + | Print entries of a C++ dictionary + | + | pprriinntt__lliisstt(...) + | Signature : (example.Example2, list) -> NoneType + | + | Print entries of a Python list + | + | pprriinntt__lliisstt__22(...) + | Signature : (example.Example2, list<unicode>) -> NoneType + | + | Print entries of a C++ list + | + | pprriinntt__sseett(...) + | Signature : (example.Example2, set) -> NoneType + | + | Print entries of a Python set + | + | pprriinntt__sseett__22(...) + | Signature : (example.Example2, set<unicode>) -> NoneType + | + | Print entries of a C++ set + | + | tthhrrooww__eexxcceeppttiioonn(...) + | Signature : (example.Example2) -> NoneType + | + | Throw an exception + | + | ttuuppllee__ppaasssstthhrroouugghh(...) + | Signature : (example.Example2, (bool, unicode, int)) -> (int, unicode, bool) + | + | Return a triple in reversed order + | + | ---------------------------------------------------------------------- + | Data and other attributes defined here: + | + | ____nneeww____ = <built-in method __new__ of example.Example2__Meta object> + | T.__new__(S, ...) -> a new object with type S, a subtype of T + | + | nneeww__iinnssttaannccee = <built-in method new_instance of PyCapsule object> + | Signature : () -> example.Example2 + | + | Return an instance + +__name__(example) = example +__name__(example.Example2) = Example2 +__module__(example.Example2) = example +__name__(example.Example2.get_set) = get_set +__module__(example.Example2.get_set) = example +Destructing Example2 diff --git a/stormpy/resources/pybind11/example/example3.cpp b/stormpy/resources/pybind11/example/example3.cpp new file mode 100644 index 000000000..3b3a6253e --- /dev/null +++ b/stormpy/resources/pybind11/example/example3.cpp @@ -0,0 +1,75 @@ +/* + example/example3.cpp -- operator overloading + + Copyright (c) 2015 Wenzel Jakob <wenzel@inf.ethz.ch> + + All rights reserved. Use of this source code is governed by a + BSD-style license that can be found in the LICENSE file. +*/ + +#include "example.h" +#include <pybind11/operators.h> + +class Vector2 { +public: + Vector2(float x, float y) : x(x), y(y) { std::cout << "Value constructor" << std::endl; } + Vector2(const Vector2 &v) : x(v.x), y(v.y) { std::cout << "Copy constructor" << std::endl; } + Vector2(Vector2 &&v) : x(v.x), y(v.y) { std::cout << "Move constructor" << std::endl; v.x = v.y = 0; } + ~Vector2() { std::cout << "Destructor." << std::endl; } + + std::string toString() const { + return "[" + std::to_string(x) + ", " + std::to_string(y) + "]"; + } + + void operator=(const Vector2 &v) { + cout << "Assignment operator" << endl; + x = v.x; + y = v.y; + } + + void operator=(Vector2 &&v) { + cout << "Move assignment operator" << endl; + x = v.x; y = v.y; v.x = v.y = 0; + } + + Vector2 operator+(const Vector2 &v) const { return Vector2(x + v.x, y + v.y); } + Vector2 operator-(const Vector2 &v) const { return Vector2(x - v.x, y - v.y); } + Vector2 operator-(float value) const { return Vector2(x - value, y - value); } + Vector2 operator+(float value) const { return Vector2(x + value, y + value); } + Vector2 operator*(float value) const { return Vector2(x * value, y * value); } + Vector2 operator/(float value) const { return Vector2(x / value, y / value); } + Vector2& operator+=(const Vector2 &v) { x += v.x; y += v.y; return *this; } + Vector2& operator-=(const Vector2 &v) { x -= v.x; y -= v.y; return *this; } + Vector2& operator*=(float v) { x *= v; y *= v; return *this; } + Vector2& operator/=(float v) { x /= v; y /= v; return *this; } + + friend Vector2 operator+(float f, const Vector2 &v) { return Vector2(f + v.x, f + v.y); } + friend Vector2 operator-(float f, const Vector2 &v) { return Vector2(f - v.x, f - v.y); } + friend Vector2 operator*(float f, const Vector2 &v) { return Vector2(f * v.x, f * v.y); } + friend Vector2 operator/(float f, const Vector2 &v) { return Vector2(f / v.x, f / v.y); } +private: + float x, y; +}; + + +void init_ex3(py::module &m) { + py::class_<Vector2>(m, "Vector2") + .def(py::init<float, float>()) + .def(py::self + py::self) + .def(py::self + float()) + .def(py::self - py::self) + .def(py::self - float()) + .def(py::self * float()) + .def(py::self / float()) + .def(py::self += py::self) + .def(py::self -= py::self) + .def(py::self *= float()) + .def(py::self /= float()) + .def(float() + py::self) + .def(float() - py::self) + .def(float() * py::self) + .def(float() / py::self) + .def("__str__", &Vector2::toString); + + m.attr("Vector") = m.attr("Vector2"); +} diff --git a/stormpy/resources/pybind11/example/example3.py b/stormpy/resources/pybind11/example/example3.py new file mode 100755 index 000000000..591ae391c --- /dev/null +++ b/stormpy/resources/pybind11/example/example3.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python +from __future__ import print_function +import sys +sys.path.append('.') + +from example import Vector2, Vector + +v1 = Vector2(1, 2) +v2 = Vector(3, -1) + +print("v1 = " + str(v1)) +print("v2 = " + str(v2)) +print("v1+v2 = " + str(v1+v2)) +print("v1-v2 = " + str(v1-v2)) +print("v1-8 = " + str(v1-8)) +print("v1+8 = " + str(v1+8)) +print("v1*8 = " + str(v1*8)) +print("v1/8 = " + str(v1/8)) +print("8-v1 = " + str(8-v1)) +print("8+v1 = " + str(8+v1)) +print("8*v1 = " + str(8*v1)) +print("8/v1 = " + str(8/v1)) + +v1 += v2 +v1 *= 2 + +print("(v1+v2)*2 = " + str(v1)) diff --git a/stormpy/resources/pybind11/example/example3.ref b/stormpy/resources/pybind11/example/example3.ref new file mode 100644 index 000000000..698b5ad6e --- /dev/null +++ b/stormpy/resources/pybind11/example/example3.ref @@ -0,0 +1,57 @@ +Value constructor +Value constructor +v1 = [1.000000, 2.000000] +v2 = [3.000000, -1.000000] +Value constructor +Copy constructor +Destructor. +Destructor. +v1+v2 = [4.000000, 1.000000] +Value constructor +Copy constructor +Destructor. +Destructor. +v1-v2 = [-2.000000, 3.000000] +Value constructor +Copy constructor +Destructor. +Destructor. +v1-8 = [-7.000000, -6.000000] +Value constructor +Copy constructor +Destructor. +Destructor. +v1+8 = [9.000000, 10.000000] +Value constructor +Copy constructor +Destructor. +Destructor. +v1*8 = [8.000000, 16.000000] +Value constructor +Copy constructor +Destructor. +Destructor. +v1/8 = [0.125000, 0.250000] +Value constructor +Copy constructor +Destructor. +Destructor. +8-v1 = [7.000000, 6.000000] +Value constructor +Copy constructor +Destructor. +Destructor. +8+v1 = [9.000000, 10.000000] +Value constructor +Copy constructor +Destructor. +Destructor. +8*v1 = [8.000000, 16.000000] +Value constructor +Copy constructor +Destructor. +Destructor. +8/v1 = [8.000000, 4.000000] +(v1+v2)*2 = [8.000000, 2.000000] +Destructor. +Destructor. diff --git a/stormpy/resources/pybind11/example/example4.cpp b/stormpy/resources/pybind11/example/example4.cpp new file mode 100644 index 000000000..e673c4a81 --- /dev/null +++ b/stormpy/resources/pybind11/example/example4.cpp @@ -0,0 +1,75 @@ +/* + example/example4.cpp -- global constants and functions, enumerations, raw byte strings + + Copyright (c) 2015 Wenzel Jakob <wenzel@inf.ethz.ch> + + All rights reserved. Use of this source code is governed by a + BSD-style license that can be found in the LICENSE file. +*/ + +#include "example.h" + +enum EMyEnumeration { + EFirstEntry = 1, + ESecondEntry +}; + +class Example4 { +public: + enum EMode { + EFirstMode = 1, + ESecondMode + }; + + static EMode test_function(EMode mode) { + std::cout << "Example4::test_function(enum=" << mode << ")" << std::endl; + return mode; + } +}; + +bool test_function1() { + std::cout << "test_function()" << std::endl; + return false; +} + +void test_function2(EMyEnumeration k) { + std::cout << "test_function(enum=" << k << ")" << std::endl; +} + +float test_function3(int i) { + std::cout << "test_function(" << i << ")" << std::endl; + return i / 2.f; +} + +py::bytes return_bytes() { + const char *data = "\x01\x00\x02\x00"; + return std::string(data, 4); +} + +void print_bytes(py::bytes bytes) { + std::string value = (std::string) bytes; + for (size_t i = 0; i < value.length(); ++i) + std::cout << "bytes[" << i << "]=" << (int) value[i] << std::endl; +} + +void init_ex4(py::module &m) { + m.def("test_function", &test_function1); + m.def("test_function", &test_function2); + m.def("test_function", &test_function3); + m.attr("some_constant") = py::int_(14); + + py::enum_<EMyEnumeration>(m, "EMyEnumeration") + .value("EFirstEntry", EFirstEntry) + .value("ESecondEntry", ESecondEntry) + .export_values(); + + py::class_<Example4> ex4_class(m, "Example4"); + ex4_class.def_static("test_function", &Example4::test_function); + py::enum_<Example4::EMode>(ex4_class, "EMode") + .value("EFirstMode", Example4::EFirstMode) + .value("ESecondMode", Example4::ESecondMode) + .export_values(); + + m.def("return_bytes", &return_bytes); + m.def("print_bytes", &print_bytes); +} diff --git a/stormpy/resources/pybind11/example/example4.py b/stormpy/resources/pybind11/example/example4.py new file mode 100755 index 000000000..37d952f2b --- /dev/null +++ b/stormpy/resources/pybind11/example/example4.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python +from __future__ import print_function +import sys +sys.path.append('.') + +from example import test_function +from example import some_constant +from example import EMyEnumeration +from example import EFirstEntry +from example import Example4 +from example import return_bytes +from example import print_bytes + +print(EMyEnumeration) +print(EMyEnumeration.EFirstEntry) +print(EMyEnumeration.ESecondEntry) +print(EFirstEntry) + +print(test_function()) +print(test_function(7)) +print(test_function(EMyEnumeration.EFirstEntry)) +print(test_function(EMyEnumeration.ESecondEntry)) +print("enum->integer = %i" % int(EMyEnumeration.ESecondEntry)) +print("integer->enum = %s" % str(EMyEnumeration(2))) + +print("A constant = " + str(some_constant)) + +print(Example4.EMode) +print(Example4.EMode.EFirstMode) +print(Example4.EFirstMode) +Example4.test_function(Example4.EFirstMode) + +print("Equality test 1: " + str( + Example4.test_function(Example4.EFirstMode) == + Example4.test_function(Example4.EFirstMode))) + +print("Inequality test 1: " + str( + Example4.test_function(Example4.EFirstMode) != + Example4.test_function(Example4.EFirstMode))) + +print("Equality test 2: " + str( + Example4.test_function(Example4.EFirstMode) == + Example4.test_function(Example4.ESecondMode))) + +print("Inequality test 2: " + str( + Example4.test_function(Example4.EFirstMode) != + Example4.test_function(Example4.ESecondMode))) + +x = { + Example4.test_function(Example4.EFirstMode): 1, + Example4.test_function(Example4.ESecondMode): 2 +} + +x[Example4.test_function(Example4.EFirstMode)] = 3 +x[Example4.test_function(Example4.ESecondMode)] = 4 +print("Hashing test = " + str(x)) + +print_bytes(return_bytes()) diff --git a/stormpy/resources/pybind11/example/example4.ref b/stormpy/resources/pybind11/example/example4.ref new file mode 100644 index 000000000..a21f62c93 --- /dev/null +++ b/stormpy/resources/pybind11/example/example4.ref @@ -0,0 +1,40 @@ +<class 'example.EMyEnumeration'> +EMyEnumeration.EFirstEntry +EMyEnumeration.ESecondEntry +EMyEnumeration.EFirstEntry +test_function() +False +test_function(7) +3.5 +test_function(enum=1) +None +test_function(enum=2) +None +enum->integer = 2 +integer->enum = EMyEnumeration.ESecondEntry +A constant = 14 +<class 'example.EMode'> +EMode.EFirstMode +EMode.EFirstMode +Example4::test_function(enum=1) +Example4::test_function(enum=1) +Example4::test_function(enum=1) +Equality test 1: True +Example4::test_function(enum=1) +Example4::test_function(enum=1) +Inequality test 1: False +Example4::test_function(enum=1) +Example4::test_function(enum=2) +Equality test 2: False +Example4::test_function(enum=1) +Example4::test_function(enum=2) +Inequality test 2: True +Example4::test_function(enum=1) +Example4::test_function(enum=2) +Example4::test_function(enum=1) +Example4::test_function(enum=2) +Hashing test = {EMode.EFirstMode: 3, EMode.ESecondMode: 4} +bytes[0]=1 +bytes[1]=0 +bytes[2]=2 +bytes[3]=0 diff --git a/stormpy/resources/pybind11/example/example5.cpp b/stormpy/resources/pybind11/example/example5.cpp new file mode 100644 index 000000000..ad24ef069 --- /dev/null +++ b/stormpy/resources/pybind11/example/example5.cpp @@ -0,0 +1,110 @@ +/* + example/example5.cpp -- inheritance, callbacks, acquiring and releasing the + global interpreter lock + + Copyright (c) 2015 Wenzel Jakob <wenzel@inf.ethz.ch> + + All rights reserved. Use of this source code is governed by a + BSD-style license that can be found in the LICENSE file. +*/ + +#include "example.h" +#include <pybind11/functional.h> + + +class Pet { +public: + Pet(const std::string &name, const std::string &species) + : m_name(name), m_species(species) {} + std::string name() const { return m_name; } + std::string species() const { return m_species; } +private: + std::string m_name; + std::string m_species; +}; + +class Dog : public Pet { +public: + Dog(const std::string &name) : Pet(name, "dog") {} + void bark() const { std::cout << "Woof!" << std::endl; } +}; + +class Rabbit : public Pet { +public: + Rabbit(const std::string &name) : Pet(name, "parrot") {} +}; + +void pet_print(const Pet &pet) { + std::cout << pet.name() + " is a " + pet.species() << std::endl; +} + +void dog_bark(const Dog &dog) { + dog.bark(); +} + +bool test_callback1(py::object func) { + func.call(); + return false; +} + +int test_callback2(py::object func) { + py::object result = func.call("Hello", 'x', true, 5); + return result.cast<int>(); +} + +void test_callback3(const std::function<int(int)> &func) { + cout << "func(43) = " << func(43)<< std::endl; +} + +std::function<int(int)> test_callback4() { + return [](int i) { return i+1; }; +} + +void init_ex5(py::module &m) { + py::class_<Pet> pet_class(m, "Pet"); + pet_class + .def(py::init<std::string, std::string>()) + .def("name", &Pet::name) + .def("species", &Pet::species); + + /* One way of declaring a subclass relationship: reference parent's class_ object */ + py::class_<Dog>(m, "Dog", pet_class) + .def(py::init<std::string>()); + + /* Another way of declaring a subclass relationship: reference parent's C++ type */ + py::class_<Rabbit>(m, "Rabbit", py::base<Pet>()) + .def(py::init<std::string>()); + + m.def("pet_print", pet_print); + m.def("dog_bark", dog_bark); + + m.def("test_callback1", &test_callback1); + m.def("test_callback2", &test_callback2); + m.def("test_callback3", &test_callback3); + m.def("test_callback4", &test_callback4); + + /* Test cleanup of lambda closure */ + + struct Payload { + Payload() { + std::cout << "Payload constructor" << std::endl; + } + ~Payload() { + std::cout << "Payload destructor" << std::endl; + } + Payload(const Payload &) { + std::cout << "Payload copy constructor" << std::endl; + } + Payload(Payload &&) { + std::cout << "Payload move constructor" << std::endl; + } + }; + + m.def("test_cleanup", []() -> std::function<void(void)> { + Payload p; + + return [p]() { + /* p should be cleaned up when the returned function is garbage collected */ + }; + }); +} diff --git a/stormpy/resources/pybind11/example/example5.py b/stormpy/resources/pybind11/example/example5.py new file mode 100755 index 000000000..ef90cfd07 --- /dev/null +++ b/stormpy/resources/pybind11/example/example5.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python +from __future__ import print_function +from functools import partial +import sys +sys.path.append('.') + +from example import Pet +from example import Dog +from example import Rabbit +from example import dog_bark +from example import pet_print + +polly = Pet('Polly', 'parrot') +molly = Dog('Molly') +roger = Rabbit('Rabbit') +print(roger.name() + " is a " + roger.species()) +pet_print(roger) +print(polly.name() + " is a " + polly.species()) +pet_print(polly) +print(molly.name() + " is a " + molly.species()) +pet_print(molly) +dog_bark(molly) +try: + dog_bark(polly) +except Exception as e: + print('The following error is expected: ' + str(e)) + +from example import test_callback1 +from example import test_callback2 +from example import test_callback3 +from example import test_callback4 +from example import test_cleanup + +def func1(): + print('Callback function 1 called!') + +def func2(a, b, c, d): + print('Callback function 2 called : ' + str(a) + ", " + str(b) + ", " + str(c) + ", "+ str(d)) + return d + +def func3(a): + print('Callback function 3 called : ' + str(a)) + +print(test_callback1(func1)) +print(test_callback2(func2)) +print(test_callback1(partial(func2, "Hello", "from", "partial", "object"))) +print(test_callback1(partial(func3, "Partial object with one argument"))) + +test_callback3(lambda i: i + 1) +f = test_callback4() +print("func(43) = %i" % f(43)) + +test_cleanup() diff --git a/stormpy/resources/pybind11/example/example5.ref b/stormpy/resources/pybind11/example/example5.ref new file mode 100644 index 000000000..bfc3cb26e --- /dev/null +++ b/stormpy/resources/pybind11/example/example5.ref @@ -0,0 +1,26 @@ +Rabbit is a parrot +Polly is a parrot +Molly is a dog +Woof! +func(43) = 44 +Payload constructor +Payload copy constructor +Payload move constructor +Payload destructor +Payload destructor +Payload destructor +Rabbit is a parrot +Polly is a parrot +Molly is a dog +The following error is expected: Incompatible function arguments. The following argument types are supported: + 1. (example.Dog) -> NoneType + +Callback function 1 called! +False +Callback function 2 called : Hello, x, True, 5 +5 +Callback function 2 called : Hello, from, partial, object +False +Callback function 3 called : Partial object with one argument +False +func(43) = 44 diff --git a/stormpy/resources/pybind11/example/example6.cpp b/stormpy/resources/pybind11/example/example6.cpp new file mode 100644 index 000000000..89db2fbab --- /dev/null +++ b/stormpy/resources/pybind11/example/example6.cpp @@ -0,0 +1,186 @@ +/* + example/example6.cpp -- supporting Pythons' sequence protocol, iterators, + etc. + + Copyright (c) 2015 Wenzel Jakob <wenzel@inf.ethz.ch> + + All rights reserved. Use of this source code is governed by a + BSD-style license that can be found in the LICENSE file. +*/ + +#include "example.h" +#include <pybind11/operators.h> +#include <pybind11/stl.h> + +class Sequence { +public: + Sequence(size_t size) : m_size(size) { + std::cout << "Value constructor: Creating a sequence with " << m_size << " entries" << std::endl; + m_data = new float[size]; + memset(m_data, 0, sizeof(float) * size); + } + + Sequence(const std::vector<float> &value) : m_size(value.size()) { + std::cout << "Value constructor: Creating a sequence with " << m_size << " entries" << std::endl; + m_data = new float[m_size]; + memcpy(m_data, &value[0], sizeof(float) * m_size); + } + + Sequence(const Sequence &s) : m_size(s.m_size) { + std::cout << "Copy constructor: Creating a sequence with " << m_size << " entries" << std::endl; + m_data = new float[m_size]; + memcpy(m_data, s.m_data, sizeof(float)*m_size); + } + + Sequence(Sequence &&s) : m_size(s.m_size), m_data(s.m_data) { + std::cout << "Move constructor: Creating a sequence with " << m_size << " entries" << std::endl; + s.m_size = 0; + s.m_data = nullptr; + } + + ~Sequence() { + std::cout << "Freeing a sequence with " << m_size << " entries" << std::endl; + delete[] m_data; + } + + Sequence &operator=(const Sequence &s) { + std::cout << "Assignment operator: Creating a sequence with " << s.m_size << " entries" << std::endl; + delete[] m_data; + m_size = s.m_size; + m_data = new float[m_size]; + memcpy(m_data, s.m_data, sizeof(float)*m_size); + return *this; + } + + Sequence &operator=(Sequence &&s) { + std::cout << "Move assignment operator: Creating a sequence with " << s.m_size << " entries" << std::endl; + if (&s != this) { + delete[] m_data; + m_size = s.m_size; + m_data = s.m_data; + s.m_size = 0; + s.m_data = nullptr; + } + return *this; + } + + bool operator==(const Sequence &s) const { + if (m_size != s.size()) + return false; + for (size_t i=0; i<m_size; ++i) + if (m_data[i] != s[i]) + return false; + return true; + } + + bool operator!=(const Sequence &s) const { + return !operator==(s); + } + + float operator[](size_t index) const { + return m_data[index]; + } + + float &operator[](size_t index) { + return m_data[index]; + } + + bool contains(float v) const { + for (size_t i=0; i<m_size; ++i) + if (v == m_data[i]) + return true; + return false; + } + + Sequence reversed() const { + Sequence result(m_size); + for (size_t i=0; i<m_size; ++i) + result[m_size-i-1] = m_data[i]; + return result; + } + + size_t size() const { return m_size; } + + const float *begin() const { return m_data; } + const float *end() const { return m_data+m_size; } + +private: + size_t m_size; + float *m_data; +}; + +void init_ex6(py::module &m) { + py::class_<Sequence> seq(m, "Sequence"); + + seq.def(py::init<size_t>()) + .def(py::init<const std::vector<float>&>()) + /// Bare bones interface + .def("__getitem__", [](const Sequence &s, size_t i) { + if (i >= s.size()) + throw py::index_error(); + return s[i]; + }) + .def("__setitem__", [](Sequence &s, size_t i, float v) { + if (i >= s.size()) + throw py::index_error(); + s[i] = v; + }) + .def("__len__", &Sequence::size) + /// Optional sequence protocol operations + .def("__iter__", [](const Sequence &s) { return py::make_iterator(s.begin(), s.end()); }, + py::keep_alive<0, 1>() /* Essential: keep object alive while iterator exists */) + .def("__contains__", [](const Sequence &s, float v) { return s.contains(v); }) + .def("__reversed__", [](const Sequence &s) -> Sequence { return s.reversed(); }) + /// Slicing protocol (optional) + .def("__getitem__", [](const Sequence &s, py::slice slice) -> Sequence* { + py::ssize_t start, stop, step, slicelength; + if (!slice.compute(s.size(), &start, &stop, &step, &slicelength)) + throw py::error_already_set(); + Sequence *seq = new Sequence(slicelength); + for (int i=0; i<slicelength; ++i) { + (*seq)[i] = s[start]; start += step; + } + return seq; + }) + .def("__setitem__", [](Sequence &s, py::slice slice, const Sequence &value) { + py::ssize_t start, stop, step, slicelength; + if (!slice.compute(s.size(), &start, &stop, &step, &slicelength)) + throw py::error_already_set(); + if ((size_t) slicelength != value.size()) + throw std::runtime_error("Left and right hand size of slice assignment have different sizes!"); + for (int i=0; i<slicelength; ++i) { + s[start] = value[i]; start += step; + } + }) + /// Comparisons + .def(py::self == py::self) + .def(py::self != py::self); + // Could also define py::self + py::self for concatenation, etc. + +#if 0 + // Obsolete: special data structure for exposing custom iterator types to python + // kept here for illustrative purposes because there might be some use cases which + // are not covered by the much simpler py::make_iterator + + struct PySequenceIterator { + PySequenceIterator(const Sequence &seq, py::object ref) : seq(seq), ref(ref) { } + + float next() { + if (index == seq.size()) + throw py::stop_iteration(); + return seq[index++]; + } + + const Sequence &seq; + py::object ref; // keep a reference + size_t index = 0; + }; + + py::class_<PySequenceIterator>(seq, "Iterator") + .def("__iter__", [](PySequenceIterator &it) -> PySequenceIterator& { return it; }) + .def("__next__", &PySequenceIterator::next); + + On the actual Sequence object, the iterator would be constructed as follows: + .def("__iter__", [](py::object s) { return PySequenceIterator(s.cast<const Sequence &>(), s); }) +#endif +} diff --git a/stormpy/resources/pybind11/example/example6.py b/stormpy/resources/pybind11/example/example6.py new file mode 100755 index 000000000..5a014dda9 --- /dev/null +++ b/stormpy/resources/pybind11/example/example6.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python +from __future__ import print_function +import sys +sys.path.append('.') + +from example import Sequence + +s = Sequence(5) +print("s = " + str(s)) +print("len(s) = " + str(len(s))) +print("s[0], s[3] = %f %f" % (s[0], s[3])) +print('12.34 in s: ' + str(12.34 in s)) +s[0], s[3] = 12.34, 56.78 +print('12.34 in s: ' + str(12.34 in s)) +print("s[0], s[3] = %f %f" % (s[0], s[3])) +rev = reversed(s) +rev2 = s[::-1] +print("rev[0], rev[1], rev[2], rev[3], rev[4] = %f %f %f %f %f" % (rev[0], rev[1], rev[2], rev[3], rev[4])) + +for i in rev: + print(i, end=' ') +print('') +for i in rev2: + print(i, end=' ') +print('') +print(rev == rev2) +rev[0::2] = Sequence([2.0, 2.0, 2.0]) +for i in rev: + print(i, end=' ') +print('') diff --git a/stormpy/resources/pybind11/example/example6.ref b/stormpy/resources/pybind11/example/example6.ref new file mode 100644 index 000000000..bc369023f --- /dev/null +++ b/stormpy/resources/pybind11/example/example6.ref @@ -0,0 +1,21 @@ +Value constructor: Creating a sequence with 5 entries +s = <example.Sequence object at 0x1033bd8d0> +len(s) = 5 +s[0], s[3] = 0.000000 0.000000 +12.34 in s: False +12.34 in s: True +s[0], s[3] = 12.340000 56.779999 +Value constructor: Creating a sequence with 5 entries +Copy constructor: Creating a sequence with 5 entries +Freeing a sequence with 5 entries +Value constructor: Creating a sequence with 5 entries +rev[0], rev[1], rev[2], rev[3], rev[4] = 0.000000 56.779999 0.000000 0.000000 12.340000 +0.0 56.7799987793 0.0 0.0 12.3400001526 +0.0 56.7799987793 0.0 0.0 12.3400001526 +True +Value constructor: Creating a sequence with 3 entries +Freeing a sequence with 3 entries +2.0 56.7799987793 2.0 0.0 2.0 +Freeing a sequence with 5 entries +Freeing a sequence with 5 entries +Freeing a sequence with 5 entries diff --git a/stormpy/resources/pybind11/example/example7.cpp b/stormpy/resources/pybind11/example/example7.cpp new file mode 100644 index 000000000..b68b55396 --- /dev/null +++ b/stormpy/resources/pybind11/example/example7.cpp @@ -0,0 +1,115 @@ +/* + example/example7.cpp -- supporting Pythons' buffer protocol + + Copyright (c) 2015 Wenzel Jakob <wenzel@inf.ethz.ch> + + All rights reserved. Use of this source code is governed by a + BSD-style license that can be found in the LICENSE file. +*/ + +#include "example.h" + +class Matrix { +public: + Matrix(size_t rows, size_t cols) : m_rows(rows), m_cols(cols) { + std::cout << "Value constructor: Creating a " << rows << "x" << cols << " matrix " << std::endl; + m_data = new float[rows*cols]; + memset(m_data, 0, sizeof(float) * rows * cols); + } + + Matrix(const Matrix &s) : m_rows(s.m_rows), m_cols(s.m_cols) { + std::cout << "Copy constructor: Creating a " << m_rows << "x" << m_cols << " matrix " << std::endl; + m_data = new float[m_rows * m_cols]; + memcpy(m_data, s.m_data, sizeof(float) * m_rows * m_cols); + } + + Matrix(Matrix &&s) : m_rows(s.m_rows), m_cols(s.m_cols), m_data(s.m_data) { + std::cout << "Move constructor: Creating a " << m_rows << "x" << m_cols << " matrix " << std::endl; + s.m_rows = 0; + s.m_cols = 0; + s.m_data = nullptr; + } + + ~Matrix() { + std::cout << "Freeing a " << m_rows << "x" << m_cols << " matrix " << std::endl; + delete[] m_data; + } + + Matrix &operator=(const Matrix &s) { + std::cout << "Assignment operator : Creating a " << s.m_rows << "x" << s.m_cols << " matrix " << std::endl; + delete[] m_data; + m_rows = s.m_rows; + m_cols = s.m_cols; + m_data = new float[m_rows * m_cols]; + memcpy(m_data, s.m_data, sizeof(float) * m_rows * m_cols); + return *this; + } + + Matrix &operator=(Matrix &&s) { + std::cout << "Move assignment operator : Creating a " << s.m_rows << "x" << s.m_cols << " matrix " << std::endl; + if (&s != this) { + delete[] m_data; + m_rows = s.m_rows; m_cols = s.m_cols; m_data = s.m_data; + s.m_rows = 0; s.m_cols = 0; s.m_data = nullptr; + } + return *this; + } + + float operator()(size_t i, size_t j) const { + return m_data[i*m_cols + j]; + } + + float &operator()(size_t i, size_t j) { + return m_data[i*m_cols + j]; + } + + float *data() { return m_data; } + + size_t rows() const { return m_rows; } + size_t cols() const { return m_cols; } +private: + size_t m_rows; + size_t m_cols; + float *m_data; +}; + +void init_ex7(py::module &m) { + py::class_<Matrix> mtx(m, "Matrix"); + + mtx.def(py::init<size_t, size_t>()) + /// Construct from a buffer + .def("__init__", [](Matrix &v, py::buffer b) { + py::buffer_info info = b.request(); + if (info.format != py::format_descriptor<float>::value() || info.ndim != 2) + throw std::runtime_error("Incompatible buffer format!"); + new (&v) Matrix(info.shape[0], info.shape[1]); + memcpy(v.data(), info.ptr, sizeof(float) * v.rows() * v.cols()); + }) + + .def("rows", &Matrix::rows) + .def("cols", &Matrix::cols) + + /// Bare bones interface + .def("__getitem__", [](const Matrix &m, std::pair<size_t, size_t> i) { + if (i.first >= m.rows() || i.second >= m.cols()) + throw py::index_error(); + return m(i.first, i.second); + }) + .def("__setitem__", [](Matrix &m, std::pair<size_t, size_t> i, float v) { + if (i.first >= m.rows() || i.second >= m.cols()) + throw py::index_error(); + m(i.first, i.second) = v; + }) + /// Provide buffer access + .def_buffer([](Matrix &m) -> py::buffer_info { + return py::buffer_info( + m.data(), /* Pointer to buffer */ + sizeof(float), /* Size of one scalar */ + py::format_descriptor<float>::value(), /* Python struct-style format descriptor */ + 2, /* Number of dimensions */ + { m.rows(), m.cols() }, /* Buffer dimensions */ + { sizeof(float) * m.rows(), /* Strides (in bytes) for each index */ + sizeof(float) } + ); + }); +} diff --git a/stormpy/resources/pybind11/example/example7.py b/stormpy/resources/pybind11/example/example7.py new file mode 100755 index 000000000..62d330174 --- /dev/null +++ b/stormpy/resources/pybind11/example/example7.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python +from __future__ import print_function +import sys +sys.path.append('.') + +from example import Matrix + +try: + import numpy as np +except ImportError: + print('NumPy missing') + exit(0) + +m = Matrix(5, 5) + +print(m[2, 3]) +m[2, 3] = 4 +print(m[2, 3]) + +m2 = np.array(m, copy=False) +print(m2) +print(m2[2, 3]) +m2[2, 3] = 5 +print(m[2, 3]) + +m3 = np.array([[1,2,3],[4,5,6]]).astype(np.float32) +print(m3) +m4 = Matrix(m3) +for i in range(m4.rows()): + for j in range(m4.cols()): + print(m4[i, j], end = ' ') + print() diff --git a/stormpy/resources/pybind11/example/example7.ref b/stormpy/resources/pybind11/example/example7.ref new file mode 100644 index 000000000..75db9633b --- /dev/null +++ b/stormpy/resources/pybind11/example/example7.ref @@ -0,0 +1,17 @@ +Value constructor: Creating a 5x5 matrix +0.0 +4.0 +[[ 0. 0. 0. 0. 0.] + [ 0. 0. 0. 0. 0.] + [ 0. 0. 0. 4. 0.] + [ 0. 0. 0. 0. 0.] + [ 0. 0. 0. 0. 0.]] +4.0 +5.0 +[[ 1. 2. 3.] + [ 4. 5. 6.]] +Value constructor: Creating a 2x3 matrix +1.0 2.0 3.0 +4.0 5.0 6.0 +Freeing a 2x3 matrix +Freeing a 5x5 matrix diff --git a/stormpy/resources/pybind11/example/example8.cpp b/stormpy/resources/pybind11/example/example8.cpp new file mode 100644 index 000000000..f492588bd --- /dev/null +++ b/stormpy/resources/pybind11/example/example8.cpp @@ -0,0 +1,147 @@ +/* + example/example8.cpp -- binding classes with custom reference counting, + implicit conversions between types + + Copyright (c) 2015 Wenzel Jakob <wenzel@inf.ethz.ch> + + All rights reserved. Use of this source code is governed by a + BSD-style license that can be found in the LICENSE file. +*/ + +#include "example.h" +#include "object.h" + +/// Custom object with builtin reference counting (see 'object.h' for the implementation) +class MyObject1 : public Object { +public: + MyObject1(int value) : value(value) { + std::cout << toString() << " constructor" << std::endl; + } + + std::string toString() const { + return "MyObject1[" + std::to_string(value) + "]"; + } + +protected: + virtual ~MyObject1() { + std::cout << toString() << " destructor" << std::endl; + } + +private: + int value; +}; + +/// Object managed by a std::shared_ptr<> +class MyObject2 { +public: + MyObject2(int value) : value(value) { + std::cout << toString() << " constructor" << std::endl; + } + + std::string toString() const { + return "MyObject2[" + std::to_string(value) + "]"; + } + + virtual ~MyObject2() { + std::cout << toString() << " destructor" << std::endl; + } + +private: + int value; +}; + +/// Object managed by a std::shared_ptr<>, additionally derives from std::enable_shared_from_this<> +class MyObject3 : public std::enable_shared_from_this<MyObject3> { +public: + MyObject3(int value) : value(value) { + std::cout << toString() << " constructor" << std::endl; + } + + std::string toString() const { + return "MyObject3[" + std::to_string(value) + "]"; + } + + virtual ~MyObject3() { + std::cout << toString() << " destructor" << std::endl; + } + +private: + int value; +}; + +/// Make pybind aware of the ref-counted wrapper type (s) +PYBIND11_DECLARE_HOLDER_TYPE(T, ref<T>); +PYBIND11_DECLARE_HOLDER_TYPE(T, std::shared_ptr<T>); + +Object *make_object_1() { return new MyObject1(1); } +ref<Object> make_object_2() { return new MyObject1(2); } + +MyObject1 *make_myobject1_1() { return new MyObject1(4); } +ref<MyObject1> make_myobject1_2() { return new MyObject1(5); } + +MyObject2 *make_myobject2_1() { return new MyObject2(6); } +std::shared_ptr<MyObject2> make_myobject2_2() { return std::make_shared<MyObject2>(7); } + +MyObject3 *make_myobject3_1() { return new MyObject3(8); } +std::shared_ptr<MyObject3> make_myobject3_2() { return std::make_shared<MyObject3>(9); } + +void print_object_1(const Object *obj) { std::cout << obj->toString() << std::endl; } +void print_object_2(ref<Object> obj) { std::cout << obj->toString() << std::endl; } +void print_object_3(const ref<Object> &obj) { std::cout << obj->toString() << std::endl; } +void print_object_4(const ref<Object> *obj) { std::cout << (*obj)->toString() << std::endl; } + +void print_myobject1_1(const MyObject1 *obj) { std::cout << obj->toString() << std::endl; } +void print_myobject1_2(ref<MyObject1> obj) { std::cout << obj->toString() << std::endl; } +void print_myobject1_3(const ref<MyObject1> &obj) { std::cout << obj->toString() << std::endl; } +void print_myobject1_4(const ref<MyObject1> *obj) { std::cout << (*obj)->toString() << std::endl; } + +void print_myobject2_1(const MyObject2 *obj) { std::cout << obj->toString() << std::endl; } +void print_myobject2_2(std::shared_ptr<MyObject2> obj) { std::cout << obj->toString() << std::endl; } +void print_myobject2_3(const std::shared_ptr<MyObject2> &obj) { std::cout << obj->toString() << std::endl; } +void print_myobject2_4(const std::shared_ptr<MyObject2> *obj) { std::cout << (*obj)->toString() << std::endl; } + +void print_myobject3_1(const MyObject3 *obj) { std::cout << obj->toString() << std::endl; } +void print_myobject3_2(std::shared_ptr<MyObject3> obj) { std::cout << obj->toString() << std::endl; } +void print_myobject3_3(const std::shared_ptr<MyObject3> &obj) { std::cout << obj->toString() << std::endl; } +void print_myobject3_4(const std::shared_ptr<MyObject3> *obj) { std::cout << (*obj)->toString() << std::endl; } + +void init_ex8(py::module &m) { + py::class_<Object, ref<Object>> obj(m, "Object"); + obj.def("getRefCount", &Object::getRefCount); + + py::class_<MyObject1, ref<MyObject1>>(m, "MyObject1", obj) + .def(py::init<int>()); + + m.def("make_object_1", &make_object_1); + m.def("make_object_2", &make_object_2); + m.def("make_myobject1_1", &make_myobject1_1); + m.def("make_myobject1_2", &make_myobject1_2); + m.def("print_object_1", &print_object_1); + m.def("print_object_2", &print_object_2); + m.def("print_object_3", &print_object_3); + m.def("print_object_4", &print_object_4); + m.def("print_myobject1_1", &print_myobject1_1); + m.def("print_myobject1_2", &print_myobject1_2); + m.def("print_myobject1_3", &print_myobject1_3); + m.def("print_myobject1_4", &print_myobject1_4); + + py::class_<MyObject2, std::shared_ptr<MyObject2>>(m, "MyObject2") + .def(py::init<int>()); + m.def("make_myobject2_1", &make_myobject2_1); + m.def("make_myobject2_2", &make_myobject2_2); + m.def("print_myobject2_1", &print_myobject2_1); + m.def("print_myobject2_2", &print_myobject2_2); + m.def("print_myobject2_3", &print_myobject2_3); + m.def("print_myobject2_4", &print_myobject2_4); + + py::class_<MyObject3, std::shared_ptr<MyObject3>>(m, "MyObject3") + .def(py::init<int>()); + m.def("make_myobject3_1", &make_myobject3_1); + m.def("make_myobject3_2", &make_myobject3_2); + m.def("print_myobject3_1", &print_myobject3_1); + m.def("print_myobject3_2", &print_myobject3_2); + m.def("print_myobject3_3", &print_myobject3_3); + m.def("print_myobject3_4", &print_myobject3_4); + + py::implicitly_convertible<py::int_, MyObject1>(); +} diff --git a/stormpy/resources/pybind11/example/example8.py b/stormpy/resources/pybind11/example/example8.py new file mode 100755 index 000000000..b12c5b999 --- /dev/null +++ b/stormpy/resources/pybind11/example/example8.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python +from __future__ import print_function +import sys +sys.path.append('.') + +from example import MyObject1 +from example import MyObject2 +from example import MyObject3 + +from example import make_object_1 +from example import make_object_2 +from example import make_myobject1_1 +from example import make_myobject1_2 +from example import make_myobject2_1 +from example import make_myobject2_2 +from example import make_myobject3_1 +from example import make_myobject3_2 + +from example import print_object_1 +from example import print_object_2 +from example import print_object_3 +from example import print_object_4 + +from example import print_myobject1_1 +from example import print_myobject1_2 +from example import print_myobject1_3 +from example import print_myobject1_4 + +from example import print_myobject2_1 +from example import print_myobject2_2 +from example import print_myobject2_3 +from example import print_myobject2_4 + +from example import print_myobject3_1 +from example import print_myobject3_2 +from example import print_myobject3_3 +from example import print_myobject3_4 + +for o in [make_object_1(), make_object_2(), MyObject1(3)]: + print("Reference count = %i" % o.getRefCount()) + print_object_1(o) + print_object_2(o) + print_object_3(o) + print_object_4(o) + +for o in [make_myobject1_1(), make_myobject1_2(), MyObject1(6), 7]: + print(o) + if not isinstance(o, int): + print_object_1(o) + print_object_2(o) + print_object_3(o) + print_object_4(o) + print_myobject1_1(o) + print_myobject1_2(o) + print_myobject1_3(o) + print_myobject1_4(o) + +for o in [MyObject2(8), make_myobject2_1(), make_myobject2_2()]: + print(o) + print_myobject2_1(o) + print_myobject2_2(o) + print_myobject2_3(o) + print_myobject2_4(o) + +for o in [MyObject3(9), make_myobject3_1(), make_myobject3_2()]: + print(o) + print_myobject3_1(o) + print_myobject3_2(o) + print_myobject3_3(o) + print_myobject3_4(o) diff --git a/stormpy/resources/pybind11/example/example8.ref b/stormpy/resources/pybind11/example/example8.ref new file mode 100644 index 000000000..641abd0c4 --- /dev/null +++ b/stormpy/resources/pybind11/example/example8.ref @@ -0,0 +1,243 @@ +MyObject1[1] constructor +Initialized ref from pointer 0x1347ba0 +MyObject1[2] constructor +Initialized ref from pointer 0x12b9270 +Initialized ref from ref 0x12b9270 +Destructing ref 0x12b9270 +MyObject1[3] constructor +Initialized ref from pointer 0x12a2a90 +MyObject1[1] +Created empty ref +Assigning ref 0x1347ba0 +Initialized ref from ref 0x1347ba0 +MyObject1[1] +Destructing ref 0x1347ba0 +Destructing ref 0x1347ba0 +Created empty ref +Assigning ref 0x1347ba0 +MyObject1[1] +Destructing ref 0x1347ba0 +Created empty ref +Assigning ref 0x1347ba0 +MyObject1[1] +Destructing ref 0x1347ba0 +MyObject1[2] +Created empty ref +Assigning ref 0x12b9270 +Initialized ref from ref 0x12b9270 +MyObject1[2] +Destructing ref 0x12b9270 +Destructing ref 0x12b9270 +Created empty ref +Assigning ref 0x12b9270 +MyObject1[2] +Destructing ref 0x12b9270 +Created empty ref +Assigning ref 0x12b9270 +MyObject1[2] +Destructing ref 0x12b9270 +MyObject1[3] +Created empty ref +Assigning ref 0x12a2a90 +Initialized ref from ref 0x12a2a90 +MyObject1[3] +Destructing ref 0x12a2a90 +Destructing ref 0x12a2a90 +Created empty ref +Assigning ref 0x12a2a90 +MyObject1[3] +Destructing ref 0x12a2a90 +Created empty ref +Assigning ref 0x12a2a90 +MyObject1[3] +Destructing ref 0x12a2a90 +Destructing ref 0x12b9270 +MyObject1[2] destructor +Destructing ref 0x1347ba0 +MyObject1[1] destructor +MyObject1[4] constructor +Initialized ref from pointer 0x1347ba0 +MyObject1[5] constructor +Initialized ref from pointer 0x1299190 +Initialized ref from ref 0x1299190 +Destructing ref 0x1299190 +MyObject1[6] constructor +Initialized ref from pointer 0x133e2f0 +Destructing ref 0x12a2a90 +MyObject1[3] destructor +MyObject1[4] +Created empty ref +Assigning ref 0x1347ba0 +Initialized ref from ref 0x1347ba0 +MyObject1[4] +Destructing ref 0x1347ba0 +Destructing ref 0x1347ba0 +Created empty ref +Assigning ref 0x1347ba0 +MyObject1[4] +Destructing ref 0x1347ba0 +Created empty ref +Assigning ref 0x1347ba0 +MyObject1[4] +Destructing ref 0x1347ba0 +MyObject1[4] +Created empty ref +Assigning ref 0x1347ba0 +Initialized ref from ref 0x1347ba0 +MyObject1[4] +Destructing ref 0x1347ba0 +Destructing ref 0x1347ba0 +Created empty ref +Assigning ref 0x1347ba0 +MyObject1[4] +Destructing ref 0x1347ba0 +Created empty ref +Assigning ref 0x1347ba0 +MyObject1[4] +Destructing ref 0x1347ba0 +MyObject1[5] +Created empty ref +Assigning ref 0x1299190 +Initialized ref from ref 0x1299190 +MyObject1[5] +Destructing ref 0x1299190 +Destructing ref 0x1299190 +Created empty ref +Assigning ref 0x1299190 +MyObject1[5] +Destructing ref 0x1299190 +Created empty ref +Assigning ref 0x1299190 +MyObject1[5] +Destructing ref 0x1299190 +MyObject1[5] +Created empty ref +Assigning ref 0x1299190 +Initialized ref from ref 0x1299190 +MyObject1[5] +Destructing ref 0x1299190 +Destructing ref 0x1299190 +Created empty ref +Assigning ref 0x1299190 +MyObject1[5] +Destructing ref 0x1299190 +Created empty ref +Assigning ref 0x1299190 +MyObject1[5] +Destructing ref 0x1299190 +MyObject1[6] +Created empty ref +Assigning ref 0x133e2f0 +Initialized ref from ref 0x133e2f0 +MyObject1[6] +Destructing ref 0x133e2f0 +Destructing ref 0x133e2f0 +Created empty ref +Assigning ref 0x133e2f0 +MyObject1[6] +Destructing ref 0x133e2f0 +Created empty ref +Assigning ref 0x133e2f0 +MyObject1[6] +Destructing ref 0x133e2f0 +MyObject1[6] +Created empty ref +Assigning ref 0x133e2f0 +Initialized ref from ref 0x133e2f0 +MyObject1[6] +Destructing ref 0x133e2f0 +Destructing ref 0x133e2f0 +Created empty ref +Assigning ref 0x133e2f0 +MyObject1[6] +Destructing ref 0x133e2f0 +Created empty ref +Assigning ref 0x133e2f0 +MyObject1[6] +Destructing ref 0x133e2f0 +MyObject1[7] constructor +Initialized ref from pointer 0x133f3a0 +MyObject1[7] +Destructing ref 0x133f3a0 +MyObject1[7] destructor +Created empty ref +MyObject1[7] constructor +Initialized ref from pointer 0x12a2a90 +Assigning ref 0x12a2a90 +Initialized ref from ref 0x12a2a90 +MyObject1[7] +Destructing ref 0x12a2a90 +Destructing ref 0x12a2a90 +Destructing ref 0x12a2a90 +MyObject1[7] destructor +Created empty ref +MyObject1[7] constructor +Initialized ref from pointer 0x133f3a0 +Assigning ref 0x133f3a0 +MyObject1[7] +Destructing ref 0x133f3a0 +Destructing ref 0x133f3a0 +MyObject1[7] destructor +Created empty ref +MyObject1[7] constructor +Initialized ref from pointer 0x12a2a90 +Assigning ref 0x12a2a90 +MyObject1[7] +Destructing ref 0x12a2a90 +Destructing ref 0x12a2a90 +MyObject1[7] destructor +Destructing ref 0x133e2f0 +MyObject1[6] destructor +Destructing ref 0x1299190 +MyObject1[5] destructor +Destructing ref 0x1347ba0 +MyObject1[4] destructor +MyObject2[8] constructor +MyObject2[6] constructor +MyObject2[7] constructor +MyObject2[8] +MyObject2[8] +MyObject2[8] +MyObject2[8] +MyObject2[6] +MyObject2[6] +MyObject2[6] +MyObject2[6] +MyObject2[7] +MyObject2[7] +MyObject2[7] +MyObject2[7] +MyObject2[6] destructor +MyObject2[8] destructor +MyObject3[9] constructor +MyObject3[8] constructor +MyObject3[9] constructor +MyObject2[7] destructor +MyObject3[9] +MyObject3[9] +MyObject3[9] +MyObject3[9] +MyObject3[8] +MyObject3[8] +MyObject3[8] +MyObject3[8] +MyObject3[9] +MyObject3[9] +MyObject3[9] +MyObject3[9] +MyObject3[8] destructor +MyObject3[9] destructor +Reference count = 1 +Reference count = 1 +Reference count = 1 +<example.MyObject1 object at 0x7f830b500e68> +<example.MyObject1 object at 0x7f830b4fc688> +<example.MyObject1 object at 0x7f830b4fc5a8> +7 +<example.MyObject2 object at 0x7f830b50b330> +<example.MyObject2 object at 0x7f830b50bdb0> +<example.MyObject2 object at 0x7f83098f6330> +<example.MyObject3 object at 0x7f830b50b330> +<example.MyObject3 object at 0x7f830b50bdb0> +<example.MyObject3 object at 0x7f83098f6370> +MyObject3[9] destructor diff --git a/stormpy/resources/pybind11/example/example9.cpp b/stormpy/resources/pybind11/example/example9.cpp new file mode 100644 index 000000000..f64b539a2 --- /dev/null +++ b/stormpy/resources/pybind11/example/example9.cpp @@ -0,0 +1,55 @@ +/* + example/example9.cpp -- nested modules, importing modules, and + internal references + + Copyright (c) 2015 Wenzel Jakob <wenzel@inf.ethz.ch> + + All rights reserved. Use of this source code is governed by a + BSD-style license that can be found in the LICENSE file. +*/ + +#include "example.h" + +void submodule_func() { + std::cout << "submodule_func()" << std::endl; +} + +class A { +public: + A(int v) : v(v) { std::cout << "A constructor" << std::endl; } + ~A() { std::cout << "A destructor" << std::endl; } + A(const A&) { std::cout << "A copy constructor" << std::endl; } + std::string toString() { return "A[" + std::to_string(v) + "]"; } +private: + int v; +}; + +class B { +public: + B() { std::cout << "B constructor" << std::endl; } + ~B() { std::cout << "B destructor" << std::endl; } + B(const B&) { std::cout << "B copy constructor" << std::endl; } + A &get_a1() { return a1; } + A &get_a2() { return a2; } + + A a1{1}; + A a2{2}; +}; + +void init_ex9(py::module &m) { + py::module m_sub = m.def_submodule("submodule"); + m_sub.def("submodule_func", &submodule_func); + + py::class_<A>(m_sub, "A") + .def(py::init<int>()) + .def("__repr__", &A::toString); + + py::class_<B>(m_sub, "B") + .def(py::init<>()) + .def("get_a1", &B::get_a1, "Return the internal A 1", py::return_value_policy::reference_internal) + .def("get_a2", &B::get_a2, "Return the internal A 2", py::return_value_policy::reference_internal) + .def_readwrite("a1", &B::a1) // def_readonly uses an internal reference return policy by default + .def_readwrite("a2", &B::a2); + + m.attr("OD") = py::module::import("collections").attr("OrderedDict"); +} diff --git a/stormpy/resources/pybind11/example/example9.py b/stormpy/resources/pybind11/example/example9.py new file mode 100755 index 000000000..2262fcf5c --- /dev/null +++ b/stormpy/resources/pybind11/example/example9.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python +from __future__ import print_function +import sys +sys.path.append('.') + +import example + +print(example.__name__) +print(example.submodule.__name__) + +from example.submodule import * +from example import OD + +submodule_func() + +b = B() +print(b.get_a1()) +print(b.a1) +print(b.get_a2()) +print(b.a2) + +b.a1 = A(42) +b.a2 = A(43) + +print(b.get_a1()) +print(b.a1) +print(b.get_a2()) +print(b.a2) + +print(OD([(1, 'a'), (2, 'b')])) diff --git a/stormpy/resources/pybind11/example/example9.ref b/stormpy/resources/pybind11/example/example9.ref new file mode 100644 index 000000000..9c783135c --- /dev/null +++ b/stormpy/resources/pybind11/example/example9.ref @@ -0,0 +1,22 @@ +example +example.submodule +submodule_func() +A constructor +A constructor +B constructor +A[1] +A[1] +A[2] +A[2] +A constructor +A destructor +A constructor +A destructor +A[42] +A[42] +A[43] +A[43] +OrderedDict([(1, 'a'), (2, 'b')]) +B destructor +A destructor +A destructor diff --git a/stormpy/resources/pybind11/example/issues.cpp b/stormpy/resources/pybind11/example/issues.cpp new file mode 100644 index 000000000..c9f9e8b07 --- /dev/null +++ b/stormpy/resources/pybind11/example/issues.cpp @@ -0,0 +1,47 @@ +/* + example/issues.cpp -- collection of testcases for miscellaneous issues + + Copyright (c) 2015 Wenzel Jakob <wenzel@inf.ethz.ch> + + All rights reserved. Use of this source code is governed by a + BSD-style license that can be found in the LICENSE file. +*/ + +#include "example.h" + +struct Base { + virtual void dispatch(void) const = 0; +}; + +struct DispatchIssue : Base { + virtual void dispatch(void) const { + PYBIND11_OVERLOAD_PURE(void, Base, dispatch); + } +}; + +void dispatch_issue_go(const Base * b) { b->dispatch(); } + +PYBIND11_PLUGIN(mytest) +{ + pybind11::module m("mytest", "A test"); + + + return m.ptr(); +} +void init_issues(py::module &m) { + py::module m2 = m.def_submodule("issues"); + + // #137: const char* isn't handled properly + m2.def("print_cchar", [](const char *string) { std::cout << string << std::endl; }); + + // #150: char bindings broken + m2.def("print_char", [](char c) { std::cout << c << std::endl; }); + + // #159: virtual function dispatch has problems with similar-named functions + pybind11::class_<DispatchIssue> base(m2, "DispatchIssue"); + base.alias<Base>() + .def(pybind11::init<>()) + .def("dispatch", &Base::dispatch); + + m2.def("dispatch_issue_go", &dispatch_issue_go); +} diff --git a/stormpy/resources/pybind11/example/issues.py b/stormpy/resources/pybind11/example/issues.py new file mode 100644 index 000000000..84752b0d3 --- /dev/null +++ b/stormpy/resources/pybind11/example/issues.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python +from __future__ import print_function +import sys +sys.path.append('.') + +from example.issues import print_cchar, print_char +from example.issues import DispatchIssue, dispatch_issue_go + +print_cchar("const char *") +print_char('c') + + +class PyClass1(DispatchIssue): + def dispatch(self): + print("Yay..") + + +class PyClass2(DispatchIssue): + def dispatch(self): + try: + super(PyClass2, self).dispatch() + except Exception as e: + print("Failed as expected: " + str(e)) + p = PyClass1() + dispatch_issue_go(p) + +b = PyClass2() +dispatch_issue_go(b) diff --git a/stormpy/resources/pybind11/example/issues.ref b/stormpy/resources/pybind11/example/issues.ref new file mode 100644 index 000000000..55cbdda1d --- /dev/null +++ b/stormpy/resources/pybind11/example/issues.ref @@ -0,0 +1,4 @@ +const char * +c +Failed as expected: Tried to call pure virtual function "dispatch" +Yay.. diff --git a/stormpy/resources/pybind11/example/object.h b/stormpy/resources/pybind11/example/object.h new file mode 100644 index 000000000..8097bd671 --- /dev/null +++ b/stormpy/resources/pybind11/example/object.h @@ -0,0 +1,160 @@ +#if !defined(__OBJECT_H) +#define __OBJECT_H + +#include <atomic> + +/// Reference counted object base class +class Object { +public: + /// Default constructor + Object() { } + + /// Copy constructor + Object(const Object &) : m_refCount(0) {} + + /// Return the current reference count + int getRefCount() const { return m_refCount; }; + + /// Increase the object's reference count by one + void incRef() const { ++m_refCount; } + + /** \brief Decrease the reference count of + * the object and possibly deallocate it. + * + * The object will automatically be deallocated once + * the reference count reaches zero. + */ + void decRef(bool dealloc = true) const { + --m_refCount; + if (m_refCount == 0 && dealloc) + delete this; + else if (m_refCount < 0) + throw std::runtime_error("Internal error: reference count < 0!"); + } + + virtual std::string toString() const = 0; +protected: + /** \brief Virtual protected deconstructor. + * (Will only be called by \ref ref) + */ + virtual ~Object() { } +private: + mutable std::atomic<int> m_refCount { 0 }; +}; + +/** + * \brief Reference counting helper + * + * The \a ref refeference template is a simple wrapper to store a + * pointer to an object. It takes care of increasing and decreasing + * the reference count of the object. When the last reference goes + * out of scope, the associated object will be deallocated. + * + * \ingroup libcore + */ +template <typename T> class ref { +public: + /// Create a nullptr reference + ref() : m_ptr(nullptr) { std::cout << "Created empty ref" << std::endl; } + + /// Construct a reference from a pointer + ref(T *ptr) : m_ptr(ptr) { + std::cout << "Initialized ref from pointer " << ptr<< std::endl; + if (m_ptr) ((Object *) m_ptr)->incRef(); + } + + /// Copy constructor + ref(const ref &r) : m_ptr(r.m_ptr) { + std::cout << "Initialized ref from ref " << r.m_ptr << std::endl; + if (m_ptr) + ((Object *) m_ptr)->incRef(); + } + + /// Move constructor + ref(ref &&r) : m_ptr(r.m_ptr) { + std::cout << "Initialized ref with move from ref " << r.m_ptr << std::endl; + r.m_ptr = nullptr; + } + + /// Destroy this reference + ~ref() { + std::cout << "Destructing ref " << m_ptr << std::endl; + if (m_ptr) + ((Object *) m_ptr)->decRef(); + } + + /// Move another reference into the current one + ref& operator=(ref&& r) { + std::cout << "Move-assigning ref " << r.m_ptr << std::endl; + if (*this == r) + return *this; + if (m_ptr) + ((Object *) m_ptr)->decRef(); + m_ptr = r.m_ptr; + r.m_ptr = nullptr; + return *this; + } + + /// Overwrite this reference with another reference + ref& operator=(const ref& r) { + std::cout << "Assigning ref " << r.m_ptr << std::endl; + if (m_ptr == r.m_ptr) + return *this; + if (m_ptr) + ((Object *) m_ptr)->decRef(); + m_ptr = r.m_ptr; + if (m_ptr) + ((Object *) m_ptr)->incRef(); + return *this; + } + + /// Overwrite this reference with a pointer to another object + ref& operator=(T *ptr) { + std::cout << "Assigning ptr " << ptr << " to ref" << std::endl; + if (m_ptr == ptr) + return *this; + if (m_ptr) + ((Object *) m_ptr)->decRef(); + m_ptr = ptr; + if (m_ptr) + ((Object *) m_ptr)->incRef(); + return *this; + } + + /// Compare this reference with another reference + bool operator==(const ref &r) const { return m_ptr == r.m_ptr; } + + /// Compare this reference with another reference + bool operator!=(const ref &r) const { return m_ptr != r.m_ptr; } + + /// Compare this reference with a pointer + bool operator==(const T* ptr) const { return m_ptr == ptr; } + + /// Compare this reference with a pointer + bool operator!=(const T* ptr) const { return m_ptr != ptr; } + + /// Access the object referenced by this reference + T* operator->() { return m_ptr; } + + /// Access the object referenced by this reference + const T* operator->() const { return m_ptr; } + + /// Return a C++ reference to the referenced object + T& operator*() { return *m_ptr; } + + /// Return a const C++ reference to the referenced object + const T& operator*() const { return *m_ptr; } + + /// Return a pointer to the referenced object + operator T* () { return m_ptr; } + + /// Return a const pointer to the referenced object + T* get() { return m_ptr; } + + /// Return a pointer to the referenced object + const T* get() const { return m_ptr; } +private: + T *m_ptr; +}; + +#endif /* __OBJECT_H */ diff --git a/stormpy/resources/pybind11/example/run_test.py b/stormpy/resources/pybind11/example/run_test.py new file mode 100755 index 000000000..d0967c6e2 --- /dev/null +++ b/stormpy/resources/pybind11/example/run_test.py @@ -0,0 +1,72 @@ +import sys +import os +import re +import subprocess + +remove_unicode_marker = re.compile(r'u(\'[^\']*\')') +remove_long_marker = re.compile(r'([0-9])L') +remove_hex = re.compile(r'0x[0-9a-fA-F]+') +shorten_floats = re.compile(r'([1-9][0-9]*\.[0-9]{4})[0-9]*') + +relaxed = False + +def sanitize(lines): + lines = lines.split('\n') + for i in range(len(lines)): + line = lines[i] + if line.startswith(" |"): + line = "" + line = remove_unicode_marker.sub(r'\1', line) + line = remove_long_marker.sub(r'\1', line) + line = remove_hex.sub(r'0', line) + line = shorten_floats.sub(r'\1', line) + line = line.replace('__builtin__', 'builtins') + line = line.replace('example.', '') + line = line.replace('unicode', 'str') + line = line.replace('Example4.EMode', 'EMode') + line = line.replace('example.EMode', 'EMode') + line = line.replace('method of builtins.PyCapsule instance', '') + line = line.strip() + if relaxed: + lower = line.lower() + # The precise pattern of allocations and deallocations is dependent on the compiler + # and optimization level, so we unfortunately can't reliably check it in this kind of test case + if 'constructor' in lower or 'destructor' in lower \ + or 'ref' in lower or 'freeing' in lower: + line = "" + lines[i] = line + + lines = '\n'.join(sorted([l for l in lines if l != ""])) + + print('==================') + print(lines) + return lines + +path = os.path.dirname(__file__) +if path != '': + os.chdir(path) + +if len(sys.argv) < 2: + print("Syntax: %s [--relaxed] <test name>" % sys.argv[0]) + exit(0) + +if len(sys.argv) == 3 and sys.argv[1] == '--relaxed': + del sys.argv[1] + relaxed = True + +name = sys.argv[1] +output_bytes = subprocess.check_output([sys.executable, name + ".py"], + stderr=subprocess.STDOUT) + +output = sanitize(output_bytes.decode('utf-8')) +reference = sanitize(open(name + '.ref', 'r').read()) + +if 'NumPy missing' in output: + print('Test "%s" could not be run.' % name) + exit(0) +elif output == reference: + print('Test "%s" succeeded.' % name) + exit(0) +else: + print('Test "%s" FAILED!' % name) + exit(-1) diff --git a/stormpy/resources/pybind11/include/pybind11/attr.h b/stormpy/resources/pybind11/include/pybind11/attr.h new file mode 100644 index 000000000..759feed7e --- /dev/null +++ b/stormpy/resources/pybind11/include/pybind11/attr.h @@ -0,0 +1,309 @@ +/* + pybind11/pybind11.h: Infrastructure for processing custom + type and function attributes + + Copyright (c) 2015 Wenzel Jakob <wenzel@inf.ethz.ch> + + All rights reserved. Use of this source code is governed by a + BSD-style license that can be found in the LICENSE file. +*/ + +#pragma once + +#include "cast.h" + +NAMESPACE_BEGIN(pybind11) + +template <typename T> struct arg_t; + +/// Annotation for keyword arguments +struct arg { + arg(const char *name) : name(name) { } + template <typename T> arg_t<T> operator=(const T &value); + template <typename T, size_t N> arg_t<const T *> operator=(T const (&value)[N]); + const char *name; +}; + +/// Annotation for keyword arguments with default values +template <typename T> struct arg_t : public arg { + arg_t(const char *name, const T &value, const char *descr = nullptr) + : arg(name), value(value), descr(descr) { } + T value; + const char *descr; +}; + +template <typename T> arg_t<T> arg::operator=(const T &value) { return arg_t<T>(name, value); } +template <typename T, size_t N> arg_t<const T *> arg::operator=(T const (&value)[N]) { + return operator=((const T *) value); +} + +/// Annotation for methods +struct is_method { handle class_; is_method(const handle &c) : class_(c) { } }; + +/// Annotation for parent scope +struct scope { handle value; scope(const handle &s) : value(s) { } }; + +/// Annotation for documentation +struct doc { const char *value; doc(const char *value) : value(value) { } }; + +/// Annotation for function names +struct name { const char *value; name(const char *value) : value(value) { } }; + +/// Annotation indicating that a function is an overload associated with a given "sibling" +struct sibling { handle value; sibling(const handle &value) : value(value.ptr()) { } }; + +/// Annotation indicating that a class derives from another given type +template <typename T> struct base { }; + +/// Keep patient alive while nurse lives +template <int Nurse, int Patient> struct keep_alive { }; + +NAMESPACE_BEGIN(detail) +/* Forward declarations */ +enum op_id : int; +enum op_type : int; +struct undefined_t; +template <op_id id, op_type ot, typename L = undefined_t, typename R = undefined_t> struct op_; +template <typename... Args> struct init; +inline void keep_alive_impl(int Nurse, int Patient, handle args, handle ret); + +/// Internal data structure which holds metadata about a keyword argument +struct argument_record { + const char *name; ///< Argument name + const char *descr; ///< Human-readable version of the argument value + handle value; ///< Associated Python object + + argument_record(const char *name, const char *descr, handle value) + : name(name), descr(descr), value(value) { } +}; + +/// Internal data structure which holds metadata about a bound function (signature, overloads, etc.) +struct function_record { + /// Function name + char *name = nullptr; /* why no C++ strings? They generate heavier code.. */ + + // User-specified documentation string + char *doc = nullptr; + + /// Human-readable version of the function signature + char *signature = nullptr; + + /// List of registered keyword arguments + std::vector<argument_record> args; + + /// Pointer to lambda function which converts arguments and performs the actual call + handle (*impl) (function_record *, handle, handle) = nullptr; + + /// Storage for the wrapped function pointer and captured data, if any + void *data = nullptr; + + /// Pointer to custom destructor for 'data' (if needed) + void (*free_data) (void *ptr) = nullptr; + + /// Return value policy associated with this function + return_value_policy policy = return_value_policy::automatic; + + /// True if name == '__init__' + bool is_constructor = false; + + /// Python method object + PyMethodDef *def = nullptr; + + /// Python handle to the associated class (if this is method) + handle class_; + + /// Python handle to the parent scope (a class or a module) + handle scope; + + /// Python handle to the sibling function representing an overload chain + handle sibling; + + /// Pointer to next overload + function_record *next = nullptr; +}; + +/// Special data structure which (temporarily) holds metadata about a bound class +struct type_record { + /// Handle to the parent scope + handle scope; + + /// Name of the class + const char *name = nullptr; + + // Pointer to RTTI type_info data structure + const std::type_info *type = nullptr; + + /// How large is the underlying C++ type? + size_t type_size = 0; + + /// How large is pybind11::instance<type>? + size_t instance_size = 0; + + /// Function pointer to class_<..>::init_holder + void (*init_holder)(PyObject *, const void *) = nullptr; + + /// Function pointer to class_<..>::dealloc + void (*dealloc)(PyObject *) = nullptr; + + // Pointer to RTTI type_info data structure of base class + const std::type_info *base_type = nullptr; + + /// OR: Python handle to base class + handle base_handle; + + /// Optional docstring + const char *doc = nullptr; +}; + +/** + * Partial template specializations to process custom attributes provided to + * cpp_function_ and class_. These are either used to initialize the respective + * fields in the type_record and function_record data structures or executed + * at runtime to deal with custom call policies (e.g. keep_alive). + */ +template <typename T, typename SFINAE = void> struct process_attribute; + +template <typename T> struct process_attribute_default { + /// Default implementation: do nothing + static void init(const T &, function_record *) { } + static void init(const T &, type_record *) { } + static void precall(handle) { } + static void postcall(handle, handle) { } +}; + +/// Process an attribute specifying the function's name +template <> struct process_attribute<name> : process_attribute_default<name> { + static void init(const name &n, function_record *r) { r->name = const_cast<char *>(n.value); } +}; + +/// Process an attribute specifying the function's docstring +template <> struct process_attribute<doc> : process_attribute_default<doc> { + static void init(const doc &n, function_record *r) { r->doc = const_cast<char *>(n.value); } +}; + +/// Process an attribute specifying the function's docstring (provided as a C-style string) +template <> struct process_attribute<const char *> : process_attribute_default<const char *> { + static void init(const char *d, function_record *r) { r->doc = const_cast<char *>(d); } + static void init(const char *d, type_record *r) { r->doc = const_cast<char *>(d); } +}; +template <> struct process_attribute<char *> : process_attribute<const char *> { }; + +/// Process an attribute indicating the function's return value policy +template <> struct process_attribute<return_value_policy> : process_attribute_default<return_value_policy> { + static void init(const return_value_policy &p, function_record *r) { r->policy = p; } +}; + +/// Process an attribute which indicates that this is an overloaded function associated with a given sibling +template <> struct process_attribute<sibling> : process_attribute_default<sibling> { + static void init(const sibling &s, function_record *r) { r->sibling = s.value; } +}; + +/// Process an attribute which indicates that this function is a method +template <> struct process_attribute<is_method> : process_attribute_default<is_method> { + static void init(const is_method &s, function_record *r) { r->class_ = s.class_; r->scope = s.class_; } +}; + +/// Process an attribute which indicates the parent scope of a method +template <> struct process_attribute<scope> : process_attribute_default<scope> { + static void init(const scope &s, function_record *r) { r->scope = s.value; } +}; + + +/// Process a keyword argument attribute (*without* a default value) +template <> struct process_attribute<arg> : process_attribute_default<arg> { + static void init(const arg &a, function_record *r) { + if (r->class_ && r->args.empty()) + r->args.emplace_back("self", nullptr, handle()); + r->args.emplace_back(a.name, nullptr, handle()); + } +}; + +/// Process a keyword argument attribute (*with* a default value) +template <typename T> +struct process_attribute<arg_t<T>> : process_attribute_default<arg_t<T>> { + static void init(const arg_t<T> &a, function_record *r) { + if (r->class_ && r->args.empty()) + r->args.emplace_back("self", nullptr, handle()); + + /* Convert keyword value into a Python object */ + object o = object(detail::type_caster<typename detail::intrinsic_type<T>::type>::cast( + a.value, return_value_policy::automatic, handle()), false); + + if (!o) { +#if !defined(NDEBUG) + std::string descr(typeid(T).name()); + detail::clean_type_id(descr); + descr = "'" + std::string(a.name) + ": " + descr + "'"; + if (r->class_) { + if (r->name) + descr += " in method '" + (std::string) r->class_.str() + "." + (std::string) r->name + "'"; + else + descr += " in method of '" + (std::string) r->class_.str() + "'"; + } else if (r->name) { + descr += " in function named '" + (std::string) r->name + "'"; + } + pybind11_fail("arg(): could not convert default keyword argument " + + descr + " into a Python object (type not registered yet?)"); +#else + pybind11_fail("arg(): could not convert default keyword argument " + "into a Python object (type not registered yet?). " + "Compile in debug mode for more information."); +#endif + } + r->args.emplace_back(a.name, a.descr, o.release()); + } +}; + +/// Process a parent class attribute +template <typename T> +struct process_attribute<T, typename std::enable_if<std::is_base_of<handle, T>::value>::type> : process_attribute_default<handle> { + static void init(const handle &h, type_record *r) { r->base_handle = h; } +}; + +/// Process a parent class attribute +template <typename T> +struct process_attribute<base<T>> : process_attribute_default<base<T>> { + static void init(const base<T> &, type_record *r) { r->base_type = &typeid(T); } +}; + +/*** + * Process a keep_alive call policy -- invokes keep_alive_impl during the + * pre-call handler if both Nurse, Patient != 0 and use the post-call handler + * otherwise + */ +template <int Nurse, int Patient> struct process_attribute<keep_alive<Nurse, Patient>> : public process_attribute_default<keep_alive<Nurse, Patient>> { + template <int N = Nurse, int P = Patient, typename std::enable_if<N != 0 && P != 0, int>::type = 0> + static void precall(handle args) { keep_alive_impl(Nurse, Patient, args, handle()); } + template <int N = Nurse, int P = Patient, typename std::enable_if<N != 0 && P != 0, int>::type = 0> + static void postcall(handle, handle) { } + template <int N = Nurse, int P = Patient, typename std::enable_if<N == 0 || P == 0, int>::type = 0> + static void precall(handle) { } + template <int N = Nurse, int P = Patient, typename std::enable_if<N == 0 || P == 0, int>::type = 0> + static void postcall(handle args, handle ret) { keep_alive_impl(Nurse, Patient, args, ret); } +}; + +/// Ignore that a variable is unused in compiler warnings +inline void ignore_unused(const int *) { } + +/// Recursively iterate over variadic template arguments +template <typename... Args> struct process_attributes { + static void init(const Args&... args, function_record *r) { + int unused[] = { 0, (process_attribute<typename std::decay<Args>::type>::init(args, r), 0) ... }; + ignore_unused(unused); + } + static void init(const Args&... args, type_record *r) { + int unused[] = { 0, (process_attribute<typename std::decay<Args>::type>::init(args, r), 0) ... }; + ignore_unused(unused); + } + static void precall(handle fn_args) { + int unused[] = { 0, (process_attribute<typename std::decay<Args>::type>::precall(fn_args), 0) ... }; + ignore_unused(unused); + } + static void postcall(handle fn_args, handle fn_ret) { + int unused[] = { 0, (process_attribute<typename std::decay<Args>::type>::postcall(fn_args, fn_ret), 0) ... }; + ignore_unused(unused); + } +}; + +NAMESPACE_END(detail) +NAMESPACE_END(pybind11) diff --git a/stormpy/resources/pybind11/include/pybind11/cast.h b/stormpy/resources/pybind11/include/pybind11/cast.h new file mode 100644 index 000000000..0fe35274d --- /dev/null +++ b/stormpy/resources/pybind11/include/pybind11/cast.h @@ -0,0 +1,747 @@ +/* + pybind11/cast.h: Partial template specializations to cast between + C++ and Python types + + Copyright (c) 2015 Wenzel Jakob <wenzel@inf.ethz.ch> + + All rights reserved. Use of this source code is governed by a + BSD-style license that can be found in the LICENSE file. +*/ + +#pragma once + +#include "pytypes.h" +#include "typeid.h" +#include "descr.h" +#include <array> +#include <limits> + +NAMESPACE_BEGIN(pybind11) + +/// Thin wrapper type used to treat certain data types as opaque (e.g. STL vectors, etc.) +template <typename Type> class opaque { +public: + template <typename... Args> opaque(Args&&... args) : value(std::forward<Args>(args)...) { } + operator Type&() { return value; } + operator const Type&() const { return value; } + operator Type*() { return &value; } + operator const Type*() const { return &value; } + Type* operator->() { return &value; } + const Type* operator->() const { return &value; } +private: + Type value; +}; + +NAMESPACE_BEGIN(detail) + +/// Additional type information which does not fit into the PyTypeObject +struct type_info { + PyTypeObject *type; + size_t type_size; + void (*init_holder)(PyObject *, const void *); + std::vector<PyObject *(*)(PyObject *, PyTypeObject *) > implicit_conversions; + buffer_info *(*get_buffer)(PyObject *, void *) = nullptr; + void *get_buffer_data = nullptr; +}; + +PYBIND11_NOINLINE inline internals &get_internals() { + static internals *internals_ptr = nullptr; + if (internals_ptr) + return *internals_ptr; + handle builtins(PyEval_GetBuiltins()); + const char *id = PYBIND11_INTERNALS_ID; + capsule caps(builtins[id]); + if (caps.check()) { + internals_ptr = caps; + } else { + internals_ptr = new internals(); + builtins[id] = capsule(internals_ptr); + } + return *internals_ptr; +} + +PYBIND11_NOINLINE inline detail::type_info* get_type_info(PyTypeObject *type) { + auto const &type_dict = get_internals().registered_types_py; + do { + auto it = type_dict.find(type); + if (it != type_dict.end()) + return (detail::type_info *) it->second; + type = type->tp_base; + if (!type) + pybind11_fail("pybind11::detail::get_type_info: unable to find type object!"); + } while (true); +} + +PYBIND11_NOINLINE inline detail::type_info *get_type_info(const std::type_info &tp) { + auto &types = get_internals().registered_types_cpp; + + auto it = types.find(std::type_index(tp)); + if (it != types.end()) + return (detail::type_info *) it->second; + return nullptr; +} + +PYBIND11_NOINLINE inline handle get_type_handle(const std::type_info &tp) { + detail::type_info *type_info = get_type_info(tp); + return handle(type_info ? ((PyObject *) type_info->type) : nullptr); +} + +PYBIND11_NOINLINE inline std::string error_string() { + std::string errorString; + PyThreadState *tstate = PyThreadState_GET(); + if (tstate == nullptr) + return ""; + + if (tstate->curexc_type) { + errorString += (std::string) handle(tstate->curexc_type).str(); + errorString += ": "; + } + if (tstate->curexc_value) + errorString += (std::string) handle(tstate->curexc_value).str(); + + return errorString; +} + +PYBIND11_NOINLINE inline handle get_object_handle(const void *ptr) { + auto instances = get_internals().registered_instances; + auto it = instances.find(ptr); + if (it == instances.end()) + return handle(); + return handle((PyObject *) it->second); +} + +class type_caster_generic { +public: + PYBIND11_NOINLINE type_caster_generic(const std::type_info &type_info) + : typeinfo(get_type_info(type_info)) { } + + PYBIND11_NOINLINE bool load(handle src, bool convert) { + if (!src || !typeinfo) + return false; + if (src.ptr() == Py_None) { + value = nullptr; + return true; + } else if (PyType_IsSubtype(Py_TYPE(src.ptr()), typeinfo->type)) { + value = ((instance<void> *) src.ptr())->value; + return true; + } + if (convert) { + for (auto &converter : typeinfo->implicit_conversions) { + temp = object(converter(src.ptr(), typeinfo->type), false); + if (load(temp, false)) + return true; + } + } + return false; + } + + PYBIND11_NOINLINE static handle cast(const void *_src, return_value_policy policy, handle parent, + const std::type_info *type_info, + const std::type_info *type_info_backup, + void *(*copy_constructor)(const void *), + const void *existing_holder = nullptr) { + void *src = const_cast<void *>(_src); + if (src == nullptr) + return handle(Py_None).inc_ref(); + + // avoid an issue with internal references matching their parent's address + bool dont_cache = policy == return_value_policy::reference_internal && + parent && ((instance<void> *) parent.ptr())->value == (void *) src; + + auto& internals = get_internals(); + auto it_instance = internals.registered_instances.find(src); + if (it_instance != internals.registered_instances.end() && !dont_cache) + return handle((PyObject *) it_instance->second).inc_ref(); + + auto it = internals.registered_types_cpp.find(std::type_index(*type_info)); + if (it == internals.registered_types_cpp.end()) { + type_info = type_info_backup; + it = internals.registered_types_cpp.find(std::type_index(*type_info)); + } + + if (it == internals.registered_types_cpp.end()) { + std::string tname = type_info->name(); + detail::clean_type_id(tname); + std::string msg = "Unregistered type : " + tname; + PyErr_SetString(PyExc_TypeError, msg.c_str()); + return handle(); + } + + auto tinfo = (const detail::type_info *) it->second; + object inst(PyType_GenericAlloc(tinfo->type, 0), false); + + auto wrapper = (instance<void> *) inst.ptr(); + + wrapper->value = src; + wrapper->owned = true; + wrapper->parent = nullptr; + + if (policy == return_value_policy::automatic) + policy = return_value_policy::take_ownership; + else if (policy == return_value_policy::automatic_reference) + policy = return_value_policy::reference; + + if (policy == return_value_policy::copy) { + wrapper->value = copy_constructor(wrapper->value); + if (wrapper->value == nullptr) + throw cast_error("return_value_policy = copy, but the object is non-copyable!"); + } else if (policy == return_value_policy::reference) { + wrapper->owned = false; + } else if (policy == return_value_policy::reference_internal) { + wrapper->owned = false; + wrapper->parent = parent.inc_ref().ptr(); + } + + tinfo->init_holder(inst.ptr(), existing_holder); + if (!dont_cache) + internals.registered_instances[wrapper->value] = inst.ptr(); + + return inst.release(); + } + +protected: + const type_info *typeinfo = nullptr; + void *value = nullptr; + object temp; +}; + +/* Determine suitable casting operator */ +template <typename T> +using cast_op_type = typename std::conditional<std::is_pointer<T>::value, + typename std::add_pointer<typename intrinsic_type<T>::type>::type, + typename std::add_lvalue_reference<typename intrinsic_type<T>::type>::type>::type; + +/// Generic type caster for objects stored on the heap +template <typename type, typename Enable = void> class type_caster : public type_caster_generic { +public: + static PYBIND11_DESCR name() { return type_descr(_<type>()); } + + type_caster() : type_caster_generic(typeid(type)) { } + + static handle cast(const type &src, return_value_policy policy, handle parent) { + if (policy == return_value_policy::automatic || policy == return_value_policy::automatic_reference) + policy = return_value_policy::copy; + return cast(&src, policy, parent); + } + + static handle cast(const type *src, return_value_policy policy, handle parent) { + return type_caster_generic::cast(src, policy, parent, src ? &typeid(*src) : nullptr, &typeid(type), ©_constructor); + } + + template <typename T> using cast_op_type = pybind11::detail::cast_op_type<T>; + + operator type*() { return (type *) value; } + operator type&() { return *((type *) value); } +protected: + template <typename T = type, typename std::enable_if<detail::is_copy_constructible<T>::value, int>::type = 0> + static void *copy_constructor(const void *arg) { + return (void *) new type(*((const type *) arg)); + } + template <typename T = type, typename std::enable_if<!detail::is_copy_constructible<T>::value, int>::type = 0> + static void *copy_constructor(const void *) { return nullptr; } +}; + +#define PYBIND11_TYPE_CASTER(type, py_name) \ + protected: \ + type value; \ + public: \ + static PYBIND11_DESCR name() { return type_descr(py_name); } \ + static handle cast(const type *src, return_value_policy policy, handle parent) { \ + return cast(*src, policy, parent); \ + } \ + operator type*() { return &value; } \ + operator type&() { return value; } \ + template <typename _T> using cast_op_type = pybind11::detail::cast_op_type<_T>; + +#define PYBIND11_DECLARE_HOLDER_TYPE(type, holder_type) \ + namespace pybind11 { namespace detail { \ + template <typename type> class type_caster<holder_type> \ + : public type_caster_holder<type, holder_type> { }; \ + }} + + +template <typename T> +struct type_caster< + T, typename std::enable_if<std::is_integral<T>::value || + std::is_floating_point<T>::value>::type> { + typedef typename std::conditional<sizeof(T) <= sizeof(long), long, long long>::type _py_type_0; + typedef typename std::conditional<std::is_signed<T>::value, _py_type_0, typename std::make_unsigned<_py_type_0>::type>::type _py_type_1; + typedef typename std::conditional<std::is_floating_point<T>::value, double, _py_type_1>::type py_type; +public: + + bool load(handle src, bool) { + py_type py_value; + + if (std::is_floating_point<T>::value) { + py_value = (py_type) PyFloat_AsDouble(src.ptr()); + } else if (sizeof(T) <= sizeof(long)) { + if (std::is_signed<T>::value) + py_value = (py_type) PyLong_AsLong(src.ptr()); + else + py_value = (py_type) PyLong_AsUnsignedLong(src.ptr()); + } else { + if (std::is_signed<T>::value) + py_value = (py_type) PYBIND11_LONG_AS_LONGLONG(src.ptr()); + else + py_value = (py_type) PYBIND11_LONG_AS_UNSIGNED_LONGLONG(src.ptr()); + } + + if ((py_value == (py_type) -1 && PyErr_Occurred()) || + (std::is_integral<T>::value && sizeof(py_type) != sizeof(T) && + (py_value < (py_type) std::numeric_limits<T>::min() || + py_value > (py_type) std::numeric_limits<T>::max()))) { + PyErr_Clear(); + return false; + } + + value = (T) py_value; + return true; + } + + static handle cast(T src, return_value_policy /* policy */, handle /* parent */) { + if (std::is_floating_point<T>::value) { + return PyFloat_FromDouble((double) src); + } else if (sizeof(T) <= sizeof(long)) { + if (std::is_signed<T>::value) + return PyLong_FromLong((long) src); + else + return PyLong_FromUnsignedLong((unsigned long) src); + } else { + if (std::is_signed<T>::value) + return PyLong_FromLongLong((long long) src); + else + return PyLong_FromUnsignedLongLong((unsigned long long) src); + } + } + + static handle cast(const T *src, return_value_policy policy, handle parent) { + return cast(*src, policy, parent); + } + + template <typename T2 = T, typename std::enable_if<std::is_integral<T2>::value, int>::type = 0> + static PYBIND11_DESCR name() { return type_descr(_("int")); } + + template <typename T2 = T, typename std::enable_if<!std::is_integral<T2>::value, int>::type = 0> + static PYBIND11_DESCR name() { return type_descr(_("float")); } + + operator T*() { return &value; } + operator T&() { return value; } + + template <typename T2> using cast_op_type = pybind11::detail::cast_op_type<T2>; +protected: + T value; +}; + +template <> class type_caster<void_type> { +public: + bool load(handle, bool) { return false; } + static handle cast(void_type, return_value_policy /* policy */, handle /* parent */) { + return handle(Py_None).inc_ref(); + } + PYBIND11_TYPE_CASTER(void_type, _("NoneType")); +}; + +template <> class type_caster<void> : public type_caster<void_type> { +public: + using type_caster<void_type>::cast; + + bool load(handle h, bool) { + if (h.ptr() == Py_None) { + value = nullptr; + return true; + } + capsule c(h, true); + if (!c.check()) + return false; + value = (void *) c; + return true; + } + + static handle cast(void *ptr, return_value_policy /* policy */, handle /* parent */) { + if (ptr) + return capsule(ptr).release(); + else + return handle(Py_None).inc_ref(); + } + + template <typename T> using cast_op_type = void*&; + operator void *&() { return value; } +private: + void *value = nullptr; +}; + +template <> class type_caster<std::nullptr_t> : public type_caster<void_type> { }; + +template <> class type_caster<bool> { +public: + bool load(handle src, bool) { + if (src.ptr() == Py_True) { value = true; return true; } + else if (src.ptr() == Py_False) { value = false; return true; } + else return false; + } + static handle cast(bool src, return_value_policy /* policy */, handle /* parent */) { + return handle(src ? Py_True : Py_False).inc_ref(); + } + PYBIND11_TYPE_CASTER(bool, _("bool")); +}; + +template <> class type_caster<std::string> { +public: + bool load(handle src, bool) { + object temp; + handle load_src = src; + if (PyUnicode_Check(load_src.ptr())) { + temp = object(PyUnicode_AsUTF8String(load_src.ptr()), false); + if (!temp) { PyErr_Clear(); return false; } // UnicodeEncodeError + load_src = temp; + } + char *buffer; + ssize_t length; + int err = PYBIND11_BYTES_AS_STRING_AND_SIZE(load_src.ptr(), &buffer, &length); + if (err == -1) { PyErr_Clear(); return false; } // TypeError + value = std::string(buffer, length); + success = true; + return true; + } + + static handle cast(const std::string &src, return_value_policy /* policy */, handle /* parent */) { + return PyUnicode_FromStringAndSize(src.c_str(), src.length()); + } + + PYBIND11_TYPE_CASTER(std::string, _(PYBIND11_STRING_NAME)); +protected: + bool success = false; +}; + +template <typename type> class type_caster<std::unique_ptr<type>> { +public: + static handle cast(std::unique_ptr<type> &&src, return_value_policy policy, handle parent) { + handle result = type_caster<type>::cast(src.get(), policy, parent); + if (result) + src.release(); + return result; + } + static PYBIND11_DESCR name() { return type_caster<type>::name(); } +}; + +template <> class type_caster<std::wstring> { +public: + bool load(handle src, bool) { + object temp; + handle load_src = src; + if (!PyUnicode_Check(load_src.ptr())) { + temp = object(PyUnicode_FromObject(load_src.ptr()), false); + if (!temp) { PyErr_Clear(); return false; } + load_src = temp; + } + wchar_t *buffer = nullptr; + ssize_t length = -1; +#if PY_MAJOR_VERSION >= 3 + buffer = PyUnicode_AsWideCharString(load_src.ptr(), &length); +#else + temp = object( + sizeof(wchar_t) == sizeof(short) + ? PyUnicode_AsUTF16String(load_src.ptr()) + : PyUnicode_AsUTF32String(load_src.ptr()), false); + if (temp) { + int err = PYBIND11_BYTES_AS_STRING_AND_SIZE(temp.ptr(), (char **) &buffer, &length); + if (err == -1) { buffer = nullptr; } // TypeError + length = length / sizeof(wchar_t) - 1; ++buffer; // Skip BOM + } +#endif + if (!buffer) { PyErr_Clear(); return false; } + value = std::wstring(buffer, length); + success = true; + return true; + } + + static handle cast(const std::wstring &src, return_value_policy /* policy */, handle /* parent */) { + return PyUnicode_FromWideChar(src.c_str(), src.length()); + } + + PYBIND11_TYPE_CASTER(std::wstring, _(PYBIND11_STRING_NAME)); +protected: + bool success = false; +}; + +template <> class type_caster<char> : public type_caster<std::string> { +public: + bool load(handle src, bool convert) { + if (src.ptr() == Py_None) { return true; } + return type_caster<std::string>::load(src, convert); + } + + static handle cast(const char *src, return_value_policy /* policy */, handle /* parent */) { + if (src == nullptr) return handle(Py_None).inc_ref(); + return PyUnicode_FromString(src); + } + + static handle cast(char src, return_value_policy /* policy */, handle /* parent */) { + char str[2] = { src, '\0' }; + return PyUnicode_DecodeLatin1(str, 1, nullptr); + } + + operator char*() { return success ? (char *) value.c_str() : nullptr; } + operator char&() { return value[0]; } + + static PYBIND11_DESCR name() { return type_descr(_(PYBIND11_STRING_NAME)); } +}; + +template <> class type_caster<wchar_t> : public type_caster<std::wstring> { +public: + bool load(handle src, bool convert) { + if (src.ptr() == Py_None) { return true; } + return type_caster<std::wstring>::load(src, convert); + } + + static handle cast(const wchar_t *src, return_value_policy /* policy */, handle /* parent */) { + if (src == nullptr) return handle(Py_None).inc_ref(); + return PyUnicode_FromWideChar(src, wcslen(src)); + } + + static handle cast(wchar_t src, return_value_policy /* policy */, handle /* parent */) { + wchar_t wstr[2] = { src, L'\0' }; + return PyUnicode_FromWideChar(wstr, 1); + } + + operator wchar_t*() { return success ? (wchar_t *) value.c_str() : nullptr; } + operator wchar_t&() { return value[0]; } + + static PYBIND11_DESCR name() { return type_descr(_(PYBIND11_STRING_NAME)); } +}; + +template <typename T1, typename T2> class type_caster<std::pair<T1, T2>> { + typedef std::pair<T1, T2> type; +public: + bool load(handle src, bool convert) { + if (!PyTuple_Check(src.ptr()) || PyTuple_Size(src.ptr()) != 2) + return false; + return first.load(PyTuple_GET_ITEM(src.ptr(), 0), convert) && + second.load(PyTuple_GET_ITEM(src.ptr(), 1), convert); + } + + static handle cast(const type &src, return_value_policy policy, handle parent) { + object o1 = object(type_caster<typename intrinsic_type<T1>::type>::cast(src.first, policy, parent), false); + object o2 = object(type_caster<typename intrinsic_type<T2>::type>::cast(src.second, policy, parent), false); + if (!o1 || !o2) + return handle(); + tuple result(2); + PyTuple_SET_ITEM(result.ptr(), 0, o1.release().ptr()); + PyTuple_SET_ITEM(result.ptr(), 1, o2.release().ptr()); + return result.release(); + } + + static PYBIND11_DESCR name() { + return type_descr( + _("(") + type_caster<typename intrinsic_type<T1>::type>::name() + + _(", ") + type_caster<typename intrinsic_type<T2>::type>::name() + _(")")); + } + + template <typename T> using cast_op_type = type; + + operator type() { + return type(first .operator typename type_caster<typename intrinsic_type<T1>::type>::template cast_op_type<T1>(), + second.operator typename type_caster<typename intrinsic_type<T2>::type>::template cast_op_type<T2>()); + } +protected: + type_caster<typename intrinsic_type<T1>::type> first; + type_caster<typename intrinsic_type<T2>::type> second; +}; + +template <typename... Tuple> class type_caster<std::tuple<Tuple...>> { + typedef std::tuple<Tuple...> type; +public: + enum { size = sizeof...(Tuple) }; + + bool load(handle src, bool convert) { + return load(src, convert, typename make_index_sequence<sizeof...(Tuple)>::type()); + } + + static handle cast(const type &src, return_value_policy policy, handle parent) { + return cast(src, policy, parent, typename make_index_sequence<size>::type()); + } + + static PYBIND11_DESCR name() { + return type_descr( + _("(") + + detail::concat(type_caster<typename intrinsic_type<Tuple>::type>::name()...) + + _(")")); + } + + template <typename ReturnValue, typename Func> typename std::enable_if<!std::is_void<ReturnValue>::value, ReturnValue>::type call(Func &&f) { + return call<ReturnValue>(std::forward<Func>(f), typename make_index_sequence<sizeof...(Tuple)>::type()); + } + + template <typename ReturnValue, typename Func> typename std::enable_if<std::is_void<ReturnValue>::value, void_type>::type call(Func &&f) { + call<ReturnValue>(std::forward<Func>(f), typename make_index_sequence<sizeof...(Tuple)>::type()); + return void_type(); + } + + template <typename T> using cast_op_type = type; + + operator type() { + return cast(typename make_index_sequence<sizeof...(Tuple)>::type()); + } + +protected: + template <typename ReturnValue, typename Func, size_t ... Index> ReturnValue call(Func &&f, index_sequence<Index...>) { + return f(std::get<Index>(value) + .operator typename type_caster<typename intrinsic_type<Tuple>::type>::template cast_op_type<Tuple>()...); + } + + template <size_t ... Index> type cast(index_sequence<Index...>) { + return type(std::get<Index>(value) + .operator typename type_caster<typename intrinsic_type<Tuple>::type>::template cast_op_type<Tuple>()...); + } + + template <size_t ... Indices> bool load(handle src, bool convert, index_sequence<Indices...>) { + if (!PyTuple_Check(src.ptr()) || PyTuple_Size(src.ptr()) != size) + return false; + std::array<bool, size> success {{ + (PyTuple_GET_ITEM(src.ptr(), Indices) != nullptr ? std::get<Indices>(value).load(PyTuple_GET_ITEM(src.ptr(), Indices), convert) : false)... + }}; + (void) convert; /* avoid a warning when the tuple is empty */ + for (bool r : success) + if (!r) + return false; + return true; + } + + /* Implementation: Convert a C++ tuple into a Python tuple */ + template <size_t ... Indices> static handle cast(const type &src, return_value_policy policy, handle parent, index_sequence<Indices...>) { + std::array<object, size> entries {{ + object(type_caster<typename intrinsic_type<Tuple>::type>::cast(std::get<Indices>(src), policy, parent), false)... + }}; + for (const auto &entry: entries) + if (!entry) + return handle(); + tuple result(size); + int counter = 0; + for (auto & entry: entries) + PyTuple_SET_ITEM(result.ptr(), counter++, entry.release().ptr()); + return result.release(); + } + +protected: + std::tuple<type_caster<typename intrinsic_type<Tuple>::type>...> value; +}; + +/// Type caster for holder types like std::shared_ptr, etc. +template <typename type, typename holder_type> class type_caster_holder : public type_caster<type> { +public: + using type_caster<type>::cast; + using type_caster<type>::typeinfo; + using type_caster<type>::value; + using type_caster<type>::temp; + using type_caster<type>::copy_constructor; + + bool load(handle src, bool convert) { + if (!src || !typeinfo) { + return false; + } else if (src.ptr() == Py_None) { + value = nullptr; + return true; + } else if (PyType_IsSubtype(Py_TYPE(src.ptr()), typeinfo->type)) { + auto inst = (instance<type, holder_type> *) src.ptr(); + value = (void *) inst->value; + holder = inst->holder; + return true; + } + + if (convert) { + for (auto &converter : typeinfo->implicit_conversions) { + temp = object(converter(src.ptr(), typeinfo->type), false); + if (load(temp, false)) + return true; + } + } + return false; + } + + explicit operator type*() { return this->value; } + explicit operator type&() { return *(this->value); } + explicit operator holder_type*() { return &holder; } + + // Workaround for Intel compiler bug + // see pybind11 issue 94 + #if defined(__ICC) || defined(__INTEL_COMPILER) + operator holder_type&() { return holder; } + #else + explicit operator holder_type&() { return holder; } + #endif + + static handle cast(const holder_type &src, return_value_policy policy, handle parent) { + return type_caster_generic::cast( + src.get(), policy, parent, + src.get() ? &typeid(*src.get()) : nullptr, &typeid(type), + ©_constructor, &src); + } + +protected: + holder_type holder; +}; + +template <typename T> struct handle_type_name { static PYBIND11_DESCR name() { return _<T>(); } }; +template <> struct handle_type_name<bytes> { static PYBIND11_DESCR name() { return _(PYBIND11_BYTES_NAME); } }; + +template <typename type> +struct type_caster<type, typename std::enable_if<std::is_base_of<handle, type>::value>::type> { +public: + template <typename T = type, typename std::enable_if<std::is_same<T, handle>::value, int>::type = 0> + bool load(handle src, bool /* convert */) { value = src; return value.check(); } + + template <typename T = type, typename std::enable_if<!std::is_same<T, handle>::value, int>::type = 0> + bool load(handle src, bool /* convert */) { value = type(src, true); return value.check(); } + + static handle cast(const handle &src, return_value_policy /* policy */, handle /* parent */) { + return src.inc_ref(); + } + PYBIND11_TYPE_CASTER(type, handle_type_name<type>::name()); +}; + +NAMESPACE_END(detail) + +template <typename T> inline T cast(handle handle) { + detail::type_caster<typename detail::intrinsic_type<T>::type> conv; + if (!conv.load(handle, true)) + throw cast_error("Unable to cast Python object to C++ type"); + return (T) conv; +} + +template <typename T> inline object cast(const T &value, return_value_policy policy = return_value_policy::automatic_reference, handle parent = handle()) { + if (policy == return_value_policy::automatic) + policy = std::is_pointer<T>::value ? return_value_policy::take_ownership : return_value_policy::copy; + else if (policy == return_value_policy::automatic_reference) + policy = std::is_pointer<T>::value ? return_value_policy::reference : return_value_policy::copy; + return object(detail::type_caster<typename detail::intrinsic_type<T>::type>::cast(value, policy, parent), false); +} + +template <typename T> inline T handle::cast() const { return pybind11::cast<T>(*this); } +template <> inline void handle::cast() const { return; } + +template <return_value_policy policy = return_value_policy::automatic_reference, + typename... Args> inline tuple make_tuple(Args&&... args_) { + const size_t size = sizeof...(Args); + std::array<object, size> args { + { object(detail::type_caster<typename detail::intrinsic_type<Args>::type>::cast( + std::forward<Args>(args_), policy, nullptr), false)... } + }; + for (auto &arg_value : args) + if (!arg_value) + throw cast_error("make_tuple(): unable to convert arguments to Python objects"); + tuple result(size); + int counter = 0; + for (auto &arg_value : args) + PyTuple_SET_ITEM(result.ptr(), counter++, arg_value.release().ptr()); + return result; +} + +template <typename... Args> inline object handle::call(Args&&... args) const { + tuple args_tuple = pybind11::make_tuple(std::forward<Args>(args)...); + object result(PyObject_CallObject(m_ptr, args_tuple.ptr()), false); + if (!result) + throw error_already_set(); + return result; +} + +NAMESPACE_END(pybind11) diff --git a/stormpy/resources/pybind11/include/pybind11/common.h b/stormpy/resources/pybind11/include/pybind11/common.h new file mode 100644 index 000000000..15047b859 --- /dev/null +++ b/stormpy/resources/pybind11/include/pybind11/common.h @@ -0,0 +1,285 @@ +/* + pybind11/common.h -- Basic macros + + Copyright (c) 2015 Wenzel Jakob <wenzel@inf.ethz.ch> + + All rights reserved. Use of this source code is governed by a + BSD-style license that can be found in the LICENSE file. +*/ + +#pragma once + +#if !defined(NAMESPACE_BEGIN) +# define NAMESPACE_BEGIN(name) namespace name { +#endif +#if !defined(NAMESPACE_END) +# define NAMESPACE_END(name) } +#endif + +#if !defined(PYBIND11_EXPORT) +# if defined(WIN32) || defined(_WIN32) +# define PYBIND11_EXPORT __declspec(dllexport) +# else +# define PYBIND11_EXPORT __attribute__ ((visibility("default"))) +# endif +#endif + +#if defined(_MSC_VER) +# define PYBIND11_NOINLINE __declspec(noinline) +#else +# define PYBIND11_NOINLINE __attribute__ ((noinline)) +#endif + +#define PYBIND11_VERSION_MAJOR 1 +#define PYBIND11_VERSION_MINOR 5 + +/// Include Python header, disable linking to pythonX_d.lib on Windows in debug mode +#if defined(_MSC_VER) +# define HAVE_ROUND +# pragma warning(push) +# pragma warning(disable: 4510 4610 4512 4005) +# if _DEBUG +# define _DEBUG_MARKER +# undef _DEBUG +# endif +#endif + +#include <Python.h> +#include <frameobject.h> + +#ifdef isalnum +# undef isalnum +# undef isalpha +# undef islower +# undef isspace +# undef isupper +# undef tolower +# undef toupper +#endif + +#if defined(_MSC_VER) +# if defined(_DEBUG_MARKER) +# define _DEBUG +# undef _DEBUG_MARKER +#endif +# pragma warning(pop) +#endif + +#include <vector> +#include <string> +#include <stdexcept> +#include <unordered_set> +#include <unordered_map> +#include <memory> +#include <typeindex> + +#if PY_MAJOR_VERSION >= 3 /// Compatibility macros for various Python versions +#define PYBIND11_INSTANCE_METHOD_NEW(ptr, class_) PyInstanceMethod_New(ptr) +#define PYBIND11_BYTES_CHECK PyBytes_Check +#define PYBIND11_BYTES_FROM_STRING PyBytes_FromString +#define PYBIND11_BYTES_FROM_STRING_AND_SIZE PyBytes_FromStringAndSize +#define PYBIND11_BYTES_AS_STRING_AND_SIZE PyBytes_AsStringAndSize +#define PYBIND11_BYTES_AS_STRING PyBytes_AsString +#define PYBIND11_LONG_CHECK(o) PyLong_Check(o) +#define PYBIND11_LONG_AS_LONGLONG(o) PyLong_AsLongLong(o) +#define PYBIND11_LONG_AS_UNSIGNED_LONGLONG(o) PyLong_AsUnsignedLongLong(o) +#define PYBIND11_BYTES_NAME "bytes" +#define PYBIND11_STRING_NAME "str" +#define PYBIND11_SLICE_OBJECT PyObject +#define PYBIND11_FROM_STRING PyUnicode_FromString +#define PYBIND11_OB_TYPE(ht_type) (ht_type).ob_base.ob_base.ob_type +#define PYBIND11_PLUGIN_IMPL(name) \ + extern "C" PYBIND11_EXPORT PyObject *PyInit_##name() +#else +#define PYBIND11_INSTANCE_METHOD_NEW(ptr, class_) PyMethod_New(ptr, nullptr, class_) +#define PYBIND11_BYTES_CHECK PyString_Check +#define PYBIND11_BYTES_FROM_STRING PyString_FromString +#define PYBIND11_BYTES_FROM_STRING_AND_SIZE PyString_FromStringAndSize +#define PYBIND11_BYTES_AS_STRING_AND_SIZE PyString_AsStringAndSize +#define PYBIND11_BYTES_AS_STRING PyString_AsString +#define PYBIND11_LONG_CHECK(o) (PyInt_Check(o) || PyLong_Check(o)) +#define PYBIND11_LONG_AS_LONGLONG(o) (PyInt_Check(o) ? (long long) PyLong_AsLong(o) : PyLong_AsLongLong(o)) +#define PYBIND11_LONG_AS_UNSIGNED_LONGLONG(o) (PyInt_Check(o) ? (unsigned long long) PyLong_AsUnsignedLong(o) : PyLong_AsUnsignedLongLong(o)) +#define PYBIND11_BYTES_NAME "str" +#define PYBIND11_STRING_NAME "unicode" +#define PYBIND11_SLICE_OBJECT PySliceObject +#define PYBIND11_FROM_STRING PyString_FromString +#define PYBIND11_OB_TYPE(ht_type) (ht_type).ob_type +#define PYBIND11_PLUGIN_IMPL(name) \ + extern "C" PYBIND11_EXPORT PyObject *init##name() +#endif + +#define PYBIND11_TRY_NEXT_OVERLOAD ((PyObject *) 1) // special failure return code +#define PYBIND11_STRINGIFY(x) #x +#define PYBIND11_TOSTRING(x) PYBIND11_STRINGIFY(x) +#define PYBIND11_INTERNALS_ID "__pybind11_" \ + PYBIND11_TOSTRING(PYBIND11_VERSION_MAJOR) "_" PYBIND11_TOSTRING(PYBIND11_VERSION_MINOR) "__" + +#define PYBIND11_PLUGIN(name) \ + static PyObject *pybind11_init(); \ + PYBIND11_PLUGIN_IMPL(name) { \ + try { \ + return pybind11_init(); \ + } catch (const std::exception &e) { \ + PyErr_SetString(PyExc_ImportError, e.what()); \ + return nullptr; \ + } \ + } \ + PyObject *pybind11_init() + + +NAMESPACE_BEGIN(pybind11) + +typedef Py_ssize_t ssize_t; + +/// Approach used to cast a previously unknown C++ instance into a Python object +enum class return_value_policy : int { + /** Automatic: copy objects returned as values and take ownership of objects + returned as pointers */ + automatic = 0, + /** Automatic variant 2: copy objects returned as values and reference objects + returned as pointers */ + automatic_reference, + /** Reference the object and take ownership. Python will call the + destructor and delete operator when the reference count reaches zero */ + take_ownership, + /** Reference the object, but do not take ownership (dangerous when C++ code + deletes it and Python still has a nonzero reference count) */ + reference, + /** Reference the object, but do not take ownership. The object is considered + be owned by the C++ instance whose method or property returned it. The + Python object will increase the reference count of this 'parent' by 1 */ + reference_internal, + /// Create a new copy of the returned object, which will be owned by Python + copy +}; + +/// Format strings for basic number types +template <typename type> struct format_descriptor { }; +#define PYBIND11_DECL_FMT(t, n) template<> struct format_descriptor<t> { static std::string value() { return n; }; } +PYBIND11_DECL_FMT(int8_t, "b"); PYBIND11_DECL_FMT(uint8_t, "B"); PYBIND11_DECL_FMT(int16_t, "h"); PYBIND11_DECL_FMT(uint16_t, "H"); +PYBIND11_DECL_FMT(int32_t, "i"); PYBIND11_DECL_FMT(uint32_t, "I"); PYBIND11_DECL_FMT(int64_t, "q"); PYBIND11_DECL_FMT(uint64_t, "Q"); +PYBIND11_DECL_FMT(float, "f"); PYBIND11_DECL_FMT(double, "d"); PYBIND11_DECL_FMT(bool, "?"); + +/// Information record describing a Python buffer object +struct buffer_info { + void *ptr; // Pointer to the underlying storage + size_t itemsize; // Size of individual items in bytes + size_t size; // Total number of entries + std::string format; // For homogeneous buffers, this should be set to format_descriptor<T>::value + int ndim; // Number of dimensions + std::vector<size_t> shape; // Shape of the tensor (1 entry per dimension) + std::vector<size_t> strides; // Number of entries between adjacent entries (for each per dimension) + + buffer_info(void *ptr, size_t itemsize, const std::string &format, int ndim, + const std::vector<size_t> &shape, const std::vector<size_t> &strides) + : ptr(ptr), itemsize(itemsize), size(1), format(format), + ndim(ndim), shape(shape), strides(strides) { + for (int i=0; i<ndim; ++i) size *= shape[i]; + } + + buffer_info(Py_buffer *view) + : ptr(view->buf), itemsize(view->itemsize), size(1), format(view->format), + ndim(view->ndim), shape(view->ndim), strides(view->ndim), view(view) { + for (int i = 0; i < view->ndim; ++i) { + shape[i] = (size_t) view->shape[i]; + strides[i] = (size_t) view->strides[i]; + size *= shape[i]; + } + } + + ~buffer_info() { + if (view) { PyBuffer_Release(view); delete view; } + } +private: + Py_buffer *view = nullptr; +}; + +NAMESPACE_BEGIN(detail) + +inline std::string error_string(); + +/// Core part of the 'instance' type which POD (needed to be able to use 'offsetof') +template <typename type> struct instance_essentials { + PyObject_HEAD + type *value; + PyObject *parent; + PyObject *weakrefs; + bool owned : 1; + bool constructed : 1; +}; + +/// PyObject wrapper around generic types, includes a special holder type that is responsible for lifetime management +template <typename type, typename holder_type = std::unique_ptr<type>> struct instance : instance_essentials<type> { + holder_type holder; +}; + +struct overload_hash { + inline std::size_t operator()(const std::pair<const PyObject *, const char *>& v) const { + size_t value = std::hash<const void *>()(v.first); + value ^= std::hash<const void *>()(v.second) + 0x9e3779b9 + (value<<6) + (value>>2); + return value; + } +}; + +/// Internal data struture used to track registered instances and types +struct internals { + std::unordered_map<std::type_index, void*> registered_types_cpp; // std::type_index -> type_info + std::unordered_map<const void *, void*> registered_types_py; // PyTypeObject* -> type_info + std::unordered_map<const void *, void*> registered_instances; // void * -> PyObject* + std::unordered_set<std::pair<const PyObject *, const char *>, overload_hash> inactive_overload_cache; +}; + +/// Return a reference to the current 'internals' information +inline internals &get_internals(); + +/// Index sequence for convenient template metaprogramming involving tuples +template<size_t ...> struct index_sequence { }; +template<size_t N, size_t ...S> struct make_index_sequence : make_index_sequence <N - 1, N - 1, S...> { }; +template<size_t ...S> struct make_index_sequence <0, S...> { typedef index_sequence<S...> type; }; + +/// Strip the class from a method type +template <typename T> struct remove_class {}; +template <typename C, typename R, typename... A> struct remove_class<R (C::*)(A...)> { typedef R type(A...); }; +template <typename C, typename R, typename... A> struct remove_class<R (C::*)(A...) const> { typedef R type(A...); }; + +/// Helper template to strip away type modifiers +template <typename T> struct intrinsic_type { typedef T type; }; +template <typename T> struct intrinsic_type<const T> { typedef typename intrinsic_type<T>::type type; }; +template <typename T> struct intrinsic_type<T*> { typedef typename intrinsic_type<T>::type type; }; +template <typename T> struct intrinsic_type<T&> { typedef typename intrinsic_type<T>::type type; }; +template <typename T> struct intrinsic_type<T&&> { typedef typename intrinsic_type<T>::type type; }; +template <typename T, size_t N> struct intrinsic_type<const T[N]> { typedef typename intrinsic_type<T>::type type; }; +template <typename T, size_t N> struct intrinsic_type<T[N]> { typedef typename intrinsic_type<T>::type type; }; + +/** \brief SFINAE helper class to check if a copy constructor is usable (in contrast to + * std::is_copy_constructible, this class also checks if the 'new' operator is accessible */ +template <typename T> struct is_copy_constructible { + template <typename T2> static std::true_type test(decltype(new T2(std::declval<typename std::add_lvalue_reference<T2>::type>())) *); + template <typename T2> static std::false_type test(...); + static const bool value = std::is_same<std::true_type, decltype(test<T>(nullptr))>::value; +}; + +/// Helper type to replace 'void' in some expressions +struct void_type { }; + +/// to_string variant which also accepts strings +template <typename T> inline typename std::enable_if<!std::is_enum<T>::value, std::string>::type +to_string(const T &value) { return std::to_string(value); } +template <> inline std::string to_string(const std::string &value) { return value; } +template <typename T> inline typename std::enable_if<std::is_enum<T>::value, std::string>::type +to_string(T value) { return std::to_string((int) value); } + +NAMESPACE_END(detail) + +// C++ bindings of core Python exceptions +struct stop_iteration : public std::runtime_error { public: stop_iteration(const std::string &w="") : std::runtime_error(w) {} }; +struct index_error : public std::runtime_error { public: index_error(const std::string &w="") : std::runtime_error(w) {} }; +struct error_already_set : public std::runtime_error { public: error_already_set() : std::runtime_error(detail::error_string()) {} }; +/// Thrown when pybind11::cast or handle::call fail due to a type casting error +struct cast_error : public std::runtime_error { public: cast_error(const std::string &w = "") : std::runtime_error(w) {} }; + +PYBIND11_NOINLINE inline void pybind11_fail(const char *reason) { throw std::runtime_error(reason); } +PYBIND11_NOINLINE inline void pybind11_fail(const std::string &reason) { throw std::runtime_error(reason); } + +NAMESPACE_END(pybind11) diff --git a/stormpy/resources/pybind11/include/pybind11/complex.h b/stormpy/resources/pybind11/include/pybind11/complex.h new file mode 100644 index 000000000..a140f6feb --- /dev/null +++ b/stormpy/resources/pybind11/include/pybind11/complex.h @@ -0,0 +1,45 @@ +/* + pybind11/complex.h: Complex number support + + Copyright (c) 2015 Wenzel Jakob <wenzel@inf.ethz.ch> + + All rights reserved. Use of this source code is governed by a + BSD-style license that can be found in the LICENSE file. +*/ + +#pragma once + +#include "pybind11.h" +#include <complex> + +/// glibc defines I as a macro which breaks things, e.g., boost template names +#ifdef I +# undef I +#endif + +NAMESPACE_BEGIN(pybind11) + +PYBIND11_DECL_FMT(std::complex<float>, "Zf"); +PYBIND11_DECL_FMT(std::complex<double>, "Zd"); + +NAMESPACE_BEGIN(detail) +template <typename T> class type_caster<std::complex<T>> { +public: + bool load(handle src, bool) { + Py_complex result = PyComplex_AsCComplex(src.ptr()); + if (result.real == -1.0 && PyErr_Occurred()) { + PyErr_Clear(); + return false; + } + value = std::complex<T>((T) result.real, (T) result.imag); + return true; + } + + static handle cast(const std::complex<T> &src, return_value_policy /* policy */, handle /* parent */) { + return PyComplex_FromDoubles((double) src.real(), (double) src.imag()); + } + + PYBIND11_TYPE_CASTER(std::complex<T>, _("complex")); +}; +NAMESPACE_END(detail) +NAMESPACE_END(pybind11) diff --git a/stormpy/resources/pybind11/include/pybind11/descr.h b/stormpy/resources/pybind11/include/pybind11/descr.h new file mode 100644 index 000000000..b040014dc --- /dev/null +++ b/stormpy/resources/pybind11/include/pybind11/descr.h @@ -0,0 +1,175 @@ +/* + pybind11/descr.h: Helper type for concatenating type signatures + either at runtime (C++11) or compile time (C++14) + + Copyright (c) 2015 Wenzel Jakob <wenzel@inf.ethz.ch> + + All rights reserved. Use of this source code is governed by a + BSD-style license that can be found in the LICENSE file. +*/ + +#pragma once + +#include "common.h" + +NAMESPACE_BEGIN(pybind11) +NAMESPACE_BEGIN(detail) + + +#if defined(__clang__) +# if __has_feature(cxx_return_type_deduction) && __has_feature(cxx_relaxed_constexpr) +# define PYBIND11_CPP14 +# endif +#elif defined(__GNUG__) +# if __cpp_constexpr >= 201304 && __cpp_decltype_auto >= 201304 +# define PYBIND11_CPP14 +# endif +#endif + +#if defined(PYBIND11_CPP14) /* Concatenate type signatures at compile time using C++14 */ + +template <size_t Size1, size_t Size2> class descr { + template <size_t Size1_, size_t Size2_> friend class descr; +public: + constexpr descr(char const (&text) [Size1+1], const std::type_info * const (&types)[Size2+1]) + : descr(text, types, + typename make_index_sequence<Size1>::type(), + typename make_index_sequence<Size2>::type()) { } + + constexpr const char *text() const { return m_text; } + constexpr const std::type_info * const * types() const { return m_types; } + + template <size_t OtherSize1, size_t OtherSize2> + constexpr descr<Size1 + OtherSize1, Size2 + OtherSize2> operator+(const descr<OtherSize1, OtherSize2> &other) const { + return concat(other, + typename make_index_sequence<Size1>::type(), + typename make_index_sequence<Size2>::type(), + typename make_index_sequence<OtherSize1>::type(), + typename make_index_sequence<OtherSize2>::type()); + } + +protected: + template <size_t... Indices1, size_t... Indices2> + constexpr descr( + char const (&text) [Size1+1], + const std::type_info * const (&types) [Size2+1], + index_sequence<Indices1...>, index_sequence<Indices2...>) + : m_text{text[Indices1]..., '\0'}, + m_types{types[Indices2]..., nullptr } {} + + template <size_t OtherSize1, size_t OtherSize2, size_t... Indices1, + size_t... Indices2, size_t... OtherIndices1, size_t... OtherIndices2> + constexpr descr<Size1 + OtherSize1, Size2 + OtherSize2> + concat(const descr<OtherSize1, OtherSize2> &other, + index_sequence<Indices1...>, index_sequence<Indices2...>, + index_sequence<OtherIndices1...>, index_sequence<OtherIndices2...>) const { + return descr<Size1 + OtherSize1, Size2 + OtherSize2>( + { m_text[Indices1]..., other.m_text[OtherIndices1]..., '\0' }, + { m_types[Indices2]..., other.m_types[OtherIndices2]..., nullptr } + ); + } + +protected: + char m_text[Size1 + 1]; + const std::type_info * m_types[Size2 + 1]; +}; + +template <size_t Size> constexpr descr<Size - 1, 0> _(char const(&text)[Size]) { + return descr<Size - 1, 0>(text, { nullptr }); +} + +template <size_t Rem, size_t... Digits> struct int_to_str : int_to_str<Rem/10, Rem%10, Digits...> { }; +template <size_t...Digits> struct int_to_str<0, Digits...> { + static constexpr auto digits = descr<sizeof...(Digits), 0>({ ('0' + Digits)..., '\0' }, { nullptr }); +}; + +template <size_t Size> auto constexpr _() { + return int_to_str<Size / 10, Size % 10>::digits; +} + +template <typename Type> constexpr descr<1, 1> _() { + return descr<1, 1>({ '%', '\0' }, { &typeid(Type), nullptr }); +} + +inline constexpr descr<0, 0> concat() { return _(""); } +template <size_t Size1, size_t Size2, typename... Args> auto constexpr concat(descr<Size1, Size2> descr) { return descr; } +template <size_t Size1, size_t Size2, typename... Args> auto constexpr concat(descr<Size1, Size2> descr, Args&&... args) { return descr + _(", ") + concat(args...); } +template <size_t Size1, size_t Size2> auto constexpr type_descr(descr<Size1, Size2> descr) { return _("{") + descr + _("}"); } + +#define PYBIND11_DESCR constexpr auto + +#else /* Simpler C++11 implementation based on run-time memory allocation and copying */ + +class descr { +public: + PYBIND11_NOINLINE descr(const char *text, const std::type_info * const * types) { + size_t nChars = len(text), nTypes = len(types); + m_text = new char[nChars]; + m_types = new const std::type_info *[nTypes]; + memcpy(m_text, text, nChars * sizeof(char)); + memcpy(m_types, types, nTypes * sizeof(const std::type_info *)); + } + + PYBIND11_NOINLINE descr friend operator+(descr &&d1, descr &&d2) { + descr r; + + size_t nChars1 = len(d1.m_text), nTypes1 = len(d1.m_types); + size_t nChars2 = len(d2.m_text), nTypes2 = len(d2.m_types); + + r.m_text = new char[nChars1 + nChars2 - 1]; + r.m_types = new const std::type_info *[nTypes1 + nTypes2 - 1]; + memcpy(r.m_text, d1.m_text, (nChars1-1) * sizeof(char)); + memcpy(r.m_text + nChars1 - 1, d2.m_text, nChars2 * sizeof(char)); + memcpy(r.m_types, d1.m_types, (nTypes1-1) * sizeof(std::type_info *)); + memcpy(r.m_types + nTypes1 - 1, d2.m_types, nTypes2 * sizeof(std::type_info *)); + + delete[] d1.m_text; delete[] d1.m_types; + delete[] d2.m_text; delete[] d2.m_types; + + return r; + } + + char *text() { return m_text; } + const std::type_info * * types() { return m_types; } + +protected: + PYBIND11_NOINLINE descr() { } + + template <typename T> static size_t len(const T *ptr) { // return length including null termination + const T *it = ptr; + while (*it++ != (T) 0) + ; + return it - ptr; + } + + const std::type_info **m_types = nullptr; + char *m_text = nullptr; +}; + +/* The 'PYBIND11_NOINLINE inline' combinations below are intentional to get the desired linkage while producing as little object code as possible */ + +PYBIND11_NOINLINE inline descr _(const char *text) { + const std::type_info *types[1] = { nullptr }; + return descr(text, types); +} + +template <typename Type> PYBIND11_NOINLINE descr _() { + const std::type_info *types[2] = { &typeid(Type), nullptr }; + return descr("%", types); +} + +template <size_t Size> PYBIND11_NOINLINE descr _() { + const std::type_info *types[1] = { nullptr }; + return descr(std::to_string(Size).c_str(), types); +} + +PYBIND11_NOINLINE inline descr concat() { return _(""); } +PYBIND11_NOINLINE inline descr concat(descr &&d) { return d; } +template <typename... Args> PYBIND11_NOINLINE descr concat(descr &&d, Args&&... args) { return std::move(d) + _(", ") + concat(std::forward<Args>(args)...); } +PYBIND11_NOINLINE inline descr type_descr(descr&& d) { return _("{") + std::move(d) + _("}"); } + +#define PYBIND11_DESCR descr +#endif + +NAMESPACE_END(detail) +NAMESPACE_END(pybind11) diff --git a/stormpy/resources/pybind11/include/pybind11/functional.h b/stormpy/resources/pybind11/include/pybind11/functional.h new file mode 100644 index 000000000..f00a60379 --- /dev/null +++ b/stormpy/resources/pybind11/include/pybind11/functional.h @@ -0,0 +1,46 @@ +/* + pybind11/functional.h: std::function<> support + + Copyright (c) 2015 Wenzel Jakob <wenzel@inf.ethz.ch> + + All rights reserved. Use of this source code is governed by a + BSD-style license that can be found in the LICENSE file. +*/ + +#pragma once + +#include "pybind11.h" +#include <functional> + +NAMESPACE_BEGIN(pybind11) +NAMESPACE_BEGIN(detail) + +template <typename Return, typename... Args> struct type_caster<std::function<Return(Args...)>> { + typedef std::function<Return(Args...)> type; +public: + bool load(handle src_, bool) { + src_ = detail::get_function(src_); + if (!src_ || !PyCallable_Check(src_.ptr())) + return false; + object src(src_, true); + value = [src](Args... args) -> Return { + object retval(src.call(std::move(args)...)); + /* Visual studio 2015 parser issue: need parentheses around this expression */ + return (retval.template cast<Return>()); + }; + return true; + } + + template <typename Func> + static handle cast(Func &&f_, return_value_policy policy, handle /* parent */) { + return cpp_function(std::forward<Func>(f_), policy).release(); + } + + PYBIND11_TYPE_CASTER(type, _("function<") + + type_caster<std::tuple<Args...>>::name() + _(" -> ") + + type_caster<typename intrinsic_type<Return>::type>::name() + + _(">")); +}; + +NAMESPACE_END(detail) +NAMESPACE_END(pybind11) diff --git a/stormpy/resources/pybind11/include/pybind11/numpy.h b/stormpy/resources/pybind11/include/pybind11/numpy.h new file mode 100644 index 000000000..3386876e5 --- /dev/null +++ b/stormpy/resources/pybind11/include/pybind11/numpy.h @@ -0,0 +1,393 @@ +/* + pybind11/numpy.h: Basic NumPy support, auto-vectorization support + + Copyright (c) 2015 Wenzel Jakob <wenzel@inf.ethz.ch> + + All rights reserved. Use of this source code is governed by a + BSD-style license that can be found in the LICENSE file. +*/ + +#pragma once + +#include "pybind11.h" +#include "complex.h" +#include <numeric> +#include <algorithm> + +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable: 4127) // warning C4127: Conditional expression is constant +#endif + +NAMESPACE_BEGIN(pybind11) + +template <typename type> struct npy_format_descriptor { }; + +class array : public buffer { +public: + struct API { + enum Entries { + API_PyArray_Type = 2, + API_PyArray_DescrFromType = 45, + API_PyArray_FromAny = 69, + API_PyArray_NewCopy = 85, + API_PyArray_NewFromDescr = 94, + + NPY_C_CONTIGUOUS_ = 0x0001, + NPY_F_CONTIGUOUS_ = 0x0002, + NPY_ARRAY_FORCECAST_ = 0x0010, + NPY_ENSURE_ARRAY_ = 0x0040, + NPY_BOOL_ = 0, + NPY_BYTE_, NPY_UBYTE_, + NPY_SHORT_, NPY_USHORT_, + NPY_INT_, NPY_UINT_, + NPY_LONG_, NPY_ULONG_, + NPY_LONGLONG_, NPY_ULONGLONG_, + NPY_FLOAT_, NPY_DOUBLE_, NPY_LONGDOUBLE_, + NPY_CFLOAT_, NPY_CDOUBLE_, NPY_CLONGDOUBLE_ + }; + + static API lookup() { + module m = module::import("numpy.core.multiarray"); + object c = (object) m.attr("_ARRAY_API"); +#if PY_MAJOR_VERSION >= 3 + void **api_ptr = (void **) (c ? PyCapsule_GetPointer(c.ptr(), NULL) : nullptr); +#else + void **api_ptr = (void **) (c ? PyCObject_AsVoidPtr(c.ptr()) : nullptr); +#endif + API api; + api.PyArray_Type_ = (decltype(api.PyArray_Type_)) api_ptr[API_PyArray_Type]; + api.PyArray_DescrFromType_ = (decltype(api.PyArray_DescrFromType_)) api_ptr[API_PyArray_DescrFromType]; + api.PyArray_FromAny_ = (decltype(api.PyArray_FromAny_)) api_ptr[API_PyArray_FromAny]; + api.PyArray_NewCopy_ = (decltype(api.PyArray_NewCopy_)) api_ptr[API_PyArray_NewCopy]; + api.PyArray_NewFromDescr_ = (decltype(api.PyArray_NewFromDescr_)) api_ptr[API_PyArray_NewFromDescr]; + return api; + } + + bool PyArray_Check_(PyObject *obj) const { return (bool) PyObject_TypeCheck(obj, PyArray_Type_); } + + PyObject *(*PyArray_DescrFromType_)(int); + PyObject *(*PyArray_NewFromDescr_) + (PyTypeObject *, PyObject *, int, Py_intptr_t *, + Py_intptr_t *, void *, int, PyObject *); + PyObject *(*PyArray_NewCopy_)(PyObject *, int); + PyTypeObject *PyArray_Type_; + PyObject *(*PyArray_FromAny_) (PyObject *, PyObject *, int, int, int, PyObject *); + }; + + PYBIND11_OBJECT_DEFAULT(array, buffer, lookup_api().PyArray_Check_) + + template <typename Type> array(size_t size, const Type *ptr) { + API& api = lookup_api(); + PyObject *descr = api.PyArray_DescrFromType_(npy_format_descriptor<Type>::value); + if (descr == nullptr) + pybind11_fail("NumPy: unsupported buffer format!"); + Py_intptr_t shape = (Py_intptr_t) size; + object tmp = object(api.PyArray_NewFromDescr_( + api.PyArray_Type_, descr, 1, &shape, nullptr, (void *) ptr, 0, nullptr), false); + if (ptr && tmp) + tmp = object(api.PyArray_NewCopy_(tmp.ptr(), -1 /* any order */), false); + if (!tmp) + pybind11_fail("NumPy: unable to create array!"); + m_ptr = tmp.release().ptr(); + } + + array(const buffer_info &info) { + API& api = lookup_api(); + if ((info.format.size() < 1) || (info.format.size() > 2)) + pybind11_fail("Unsupported buffer format!"); + int fmt = (int) info.format[0]; + if (info.format == "Zd") fmt = API::NPY_CDOUBLE_; + else if (info.format == "Zf") fmt = API::NPY_CFLOAT_; + + PyObject *descr = api.PyArray_DescrFromType_(fmt); + if (descr == nullptr) + pybind11_fail("NumPy: unsupported buffer format '" + info.format + "'!"); + object tmp(api.PyArray_NewFromDescr_( + api.PyArray_Type_, descr, info.ndim, (Py_intptr_t *) &info.shape[0], + (Py_intptr_t *) &info.strides[0], info.ptr, 0, nullptr), false); + if (info.ptr && tmp) + tmp = object(api.PyArray_NewCopy_(tmp.ptr(), -1 /* any order */), false); + if (!tmp) + pybind11_fail("NumPy: unable to create array!"); + m_ptr = tmp.release().ptr(); + } + +protected: + static API &lookup_api() { + static API api = API::lookup(); + return api; + } +}; + +template <typename T> class array_t : public array { +public: + PYBIND11_OBJECT_CVT(array_t, array, is_non_null, m_ptr = ensure(m_ptr)); + array_t() : array() { } + static bool is_non_null(PyObject *ptr) { return ptr != nullptr; } + static PyObject *ensure(PyObject *ptr) { + if (ptr == nullptr) + return nullptr; + API &api = lookup_api(); + PyObject *descr = api.PyArray_DescrFromType_(npy_format_descriptor<T>::value); + PyObject *result = api.PyArray_FromAny_( + ptr, descr, 0, 0, API::NPY_C_CONTIGUOUS_ | API::NPY_ENSURE_ARRAY_ + | API::NPY_ARRAY_FORCECAST_, nullptr); + Py_DECREF(ptr); + return result; + } +}; + +#define DECL_FMT(t, n) template<> struct npy_format_descriptor<t> { enum { value = array::API::n }; } +DECL_FMT(int8_t, NPY_BYTE_); DECL_FMT(uint8_t, NPY_UBYTE_); DECL_FMT(int16_t, NPY_SHORT_); +DECL_FMT(uint16_t, NPY_USHORT_); DECL_FMT(int32_t, NPY_INT_); DECL_FMT(uint32_t, NPY_UINT_); +DECL_FMT(int64_t, NPY_LONGLONG_); DECL_FMT(uint64_t, NPY_ULONGLONG_); DECL_FMT(float, NPY_FLOAT_); +DECL_FMT(double, NPY_DOUBLE_); DECL_FMT(bool, NPY_BOOL_); DECL_FMT(std::complex<float>, NPY_CFLOAT_); +DECL_FMT(std::complex<double>, NPY_CDOUBLE_); +#undef DECL_FMT + +NAMESPACE_BEGIN(detail) + +template <class T> +using array_iterator = typename std::add_pointer<T>::type; + +template <class T> +array_iterator<T> array_begin(const buffer_info& buffer) { + return array_iterator<T>(reinterpret_cast<T*>(buffer.ptr)); +} + +template <class T> +array_iterator<T> array_end(const buffer_info& buffer) { + return array_iterator<T>(reinterpret_cast<T*>(buffer.ptr) + buffer.size); +} + +class common_iterator { +public: + using container_type = std::vector<size_t>; + using value_type = container_type::value_type; + using size_type = container_type::size_type; + + common_iterator() : p_ptr(0), m_strides() {} + + common_iterator(void* ptr, const container_type& strides, const std::vector<size_t>& shape) + : p_ptr(reinterpret_cast<char*>(ptr)), m_strides(strides.size()) { + m_strides.back() = static_cast<value_type>(strides.back()); + for (size_type i = m_strides.size() - 1; i != 0; --i) { + size_type j = i - 1; + value_type s = static_cast<value_type>(shape[i]); + m_strides[j] = strides[j] + m_strides[i] - strides[i] * s; + } + } + + void increment(size_type dim) { + p_ptr += m_strides[dim]; + } + + void* data() const { + return p_ptr; + } + +private: + char* p_ptr; + container_type m_strides; +}; + +template <size_t N> class multi_array_iterator { +public: + using container_type = std::vector<size_t>; + + multi_array_iterator(const std::array<buffer_info, N> &buffers, + const std::vector<size_t> &shape) + : m_shape(shape.size()), m_index(shape.size(), 0), + m_common_iterator() { + + // Manual copy to avoid conversion warning if using std::copy + for (size_t i = 0; i < shape.size(); ++i) + m_shape[i] = static_cast<container_type::value_type>(shape[i]); + + container_type strides(shape.size()); + for (size_t i = 0; i < N; ++i) + init_common_iterator(buffers[i], shape, m_common_iterator[i], strides); + } + + multi_array_iterator& operator++() { + for (size_t j = m_index.size(); j != 0; --j) { + size_t i = j - 1; + if (++m_index[i] != m_shape[i]) { + increment_common_iterator(i); + break; + } else { + m_index[i] = 0; + } + } + return *this; + } + + template <size_t K, class T> const T& data() const { + return *reinterpret_cast<T*>(m_common_iterator[K].data()); + } + +private: + + using common_iter = common_iterator; + + void init_common_iterator(const buffer_info &buffer, + const std::vector<size_t> &shape, + common_iter &iterator, container_type &strides) { + auto buffer_shape_iter = buffer.shape.rbegin(); + auto buffer_strides_iter = buffer.strides.rbegin(); + auto shape_iter = shape.rbegin(); + auto strides_iter = strides.rbegin(); + + while (buffer_shape_iter != buffer.shape.rend()) { + if (*shape_iter == *buffer_shape_iter) + *strides_iter = static_cast<int>(*buffer_strides_iter); + else + *strides_iter = 0; + + ++buffer_shape_iter; + ++buffer_strides_iter; + ++shape_iter; + ++strides_iter; + } + + std::fill(strides_iter, strides.rend(), 0); + iterator = common_iter(buffer.ptr, strides, shape); + } + + void increment_common_iterator(size_t dim) { + for (auto &iter : m_common_iterator) + iter.increment(dim); + } + + container_type m_shape; + container_type m_index; + std::array<common_iter, N> m_common_iterator; +}; + +template <size_t N> +bool broadcast(const std::array<buffer_info, N>& buffers, int& ndim, std::vector<size_t>& shape) { + ndim = std::accumulate(buffers.begin(), buffers.end(), 0, [](int res, const buffer_info& buf) { + return std::max(res, buf.ndim); + }); + + shape = std::vector<size_t>(static_cast<size_t>(ndim), 1); + bool trivial_broadcast = true; + for (size_t i = 0; i < N; ++i) { + auto res_iter = shape.rbegin(); + bool i_trivial_broadcast = (buffers[i].size == 1) || (buffers[i].ndim == ndim); + for (auto shape_iter = buffers[i].shape.rbegin(); + shape_iter != buffers[i].shape.rend(); ++shape_iter, ++res_iter) { + + if (*res_iter == 1) + *res_iter = *shape_iter; + else if ((*shape_iter != 1) && (*res_iter != *shape_iter)) + pybind11_fail("pybind11::vectorize: incompatible size/dimension of inputs!"); + + i_trivial_broadcast = i_trivial_broadcast && (*res_iter == *shape_iter); + } + trivial_broadcast = trivial_broadcast && i_trivial_broadcast; + } + return trivial_broadcast; +} + +template <typename Func, typename Return, typename... Args> +struct vectorize_helper { + typename std::remove_reference<Func>::type f; + + template <typename T> + vectorize_helper(T&&f) : f(std::forward<T>(f)) { } + + object operator()(array_t<Args>... args) { + return run(args..., typename make_index_sequence<sizeof...(Args)>::type()); + } + + template <size_t ... Index> object run(array_t<Args>&... args, index_sequence<Index...> index) { + /* Request buffers from all parameters */ + const size_t N = sizeof...(Args); + + std::array<buffer_info, N> buffers {{ args.request()... }}; + + /* Determine dimensions parameters of output array */ + int ndim = 0; + std::vector<size_t> shape(0); + bool trivial_broadcast = broadcast(buffers, ndim, shape); + + size_t size = 1; + std::vector<size_t> strides(ndim); + if (ndim > 0) { + strides[ndim-1] = sizeof(Return); + for (int i = ndim - 1; i > 0; --i) { + strides[i - 1] = strides[i] * shape[i]; + size *= shape[i]; + } + size *= shape[0]; + } + + if (size == 1) + return cast(f(*((Args *) buffers[Index].ptr)...)); + + array result(buffer_info(nullptr, sizeof(Return), + format_descriptor<Return>::value(), + ndim, shape, strides)); + + buffer_info buf = result.request(); + Return *output = (Return *) buf.ptr; + + if(trivial_broadcast) { + /* Call the function */ + for (size_t i=0; i<size; ++i) { + output[i] = f((buffers[Index].size == 1 + ? *((Args *) buffers[Index].ptr) + : ((Args *) buffers[Index].ptr)[i])...); + } + } else { + apply_broadcast<N, Index...>(buffers, buf, index); + } + + return result; + } + + template <size_t N, size_t... Index> + void apply_broadcast(const std::array<buffer_info, N> &buffers, + buffer_info &output, index_sequence<Index...>) { + using input_iterator = multi_array_iterator<N>; + using output_iterator = array_iterator<Return>; + + input_iterator input_iter(buffers, output.shape); + output_iterator output_end = array_end<Return>(output); + + for (output_iterator iter = array_begin<Return>(output); + iter != output_end; ++iter, ++input_iter) { + *iter = f((input_iter.template data<Index, Args>())...); + } + } +}; + +template <typename T> struct handle_type_name<array_t<T>> { + static PYBIND11_DESCR name() { return _("array[") + type_caster<T>::name() + _("]"); } +}; + +NAMESPACE_END(detail) + +template <typename Func, typename Return, typename... Args> +detail::vectorize_helper<Func, Return, Args...> vectorize(const Func &f, Return (*) (Args ...)) { + return detail::vectorize_helper<Func, Return, Args...>(f); +} + +template <typename Return, typename... Args> +detail::vectorize_helper<Return (*) (Args ...), Return, Args...> vectorize(Return (*f) (Args ...)) { + return vectorize<Return (*) (Args ...), Return, Args...>(f, f); +} + +template <typename func> auto vectorize(func &&f) -> decltype( + vectorize(std::forward<func>(f), (typename detail::remove_class<decltype(&std::remove_reference<func>::type::operator())>::type *) nullptr)) { + return vectorize(std::forward<func>(f), (typename detail::remove_class<decltype( + &std::remove_reference<func>::type::operator())>::type *) nullptr); +} + +NAMESPACE_END(pybind11) + +#if defined(_MSC_VER) +#pragma warning(pop) +#endif diff --git a/stormpy/resources/pybind11/include/pybind11/operators.h b/stormpy/resources/pybind11/include/pybind11/operators.h new file mode 100644 index 000000000..b10bfe30c --- /dev/null +++ b/stormpy/resources/pybind11/include/pybind11/operators.h @@ -0,0 +1,153 @@ +/* + pybind11/operator.h: Metatemplates for operator overloading + + Copyright (c) 2015 Wenzel Jakob <wenzel@inf.ethz.ch> + + All rights reserved. Use of this source code is governed by a + BSD-style license that can be found in the LICENSE file. +*/ + +#pragma once + +#include "pybind11.h" +#include <type_traits> + +#if defined(__clang__) +# pragma clang diagnostic ignored "-Wunsequenced" // multiple unsequenced modifications to 'self' (when using def(py::self OP Type())) +#endif + +NAMESPACE_BEGIN(pybind11) +NAMESPACE_BEGIN(detail) + +/// Enumeration with all supported operator types +enum op_id : int { + op_add, op_sub, op_mul, op_div, op_mod, op_divmod, op_pow, op_lshift, + op_rshift, op_and, op_xor, op_or, op_neg, op_pos, op_abs, op_invert, + op_int, op_long, op_float, op_str, op_cmp, op_gt, op_ge, op_lt, op_le, + op_eq, op_ne, op_iadd, op_isub, op_imul, op_idiv, op_imod, op_ilshift, + op_irshift, op_iand, op_ixor, op_ior, op_complex, op_bool, op_nonzero, + op_repr, op_truediv +}; + +enum op_type : int { + op_l, /* base type on left */ + op_r, /* base type on right */ + op_u /* unary operator */ +}; + +struct self_t { }; +static const self_t self = self_t(); + +/// Type for an unused type slot +struct undefined_t { }; + +/// Don't warn about an unused variable +inline self_t __self() { return self; } + +/// base template of operator implementations +template <op_id, op_type, typename B, typename L, typename R> struct op_impl { }; + +/// Operator implementation generator +template <op_id id, op_type ot, typename L, typename R> struct op_ { + template <typename Base, typename Holder, typename... Extra> void execute(pybind11::class_<Base, Holder> &class_, const Extra&... extra) const { + typedef typename std::conditional<std::is_same<L, self_t>::value, Base, L>::type L_type; + typedef typename std::conditional<std::is_same<R, self_t>::value, Base, R>::type R_type; + typedef op_impl<id, ot, Base, L_type, R_type> op; + class_.def(op::name(), &op::execute, extra...); + } + template <typename Base, typename Holder, typename... Extra> void execute_cast(pybind11::class_<Base, Holder> &class_, const Extra&... extra) const { + typedef typename std::conditional<std::is_same<L, self_t>::value, Base, L>::type L_type; + typedef typename std::conditional<std::is_same<R, self_t>::value, Base, R>::type R_type; + typedef op_impl<id, ot, Base, L_type, R_type> op; + class_.def(op::name(), &op::execute_cast, extra...); + } +}; + +#define PYBIND11_BINARY_OPERATOR(id, rid, op, expr) \ +template <typename B, typename L, typename R> struct op_impl<op_##id, op_l, B, L, R> { \ + static char const* name() { return "__" #id "__"; } \ + static auto execute(const L &l, const R &r) -> decltype(expr) { return (expr); } \ + static B execute_cast(const L &l, const R &r) { return B(expr); } \ +}; \ +template <typename B, typename L, typename R> struct op_impl<op_##id, op_r, B, L, R> { \ + static char const* name() { return "__" #rid "__"; } \ + static auto execute(const R &r, const L &l) -> decltype(expr) { return (expr); } \ + static B execute_cast(const R &r, const L &l) { return B(expr); } \ +}; \ +inline op_<op_##id, op_l, self_t, self_t> op(const self_t &, const self_t &) { \ + return op_<op_##id, op_l, self_t, self_t>(); \ +} \ +template <typename T> op_<op_##id, op_l, self_t, T> op(const self_t &, const T &) { \ + return op_<op_##id, op_l, self_t, T>(); \ +} \ +template <typename T> op_<op_##id, op_r, T, self_t> op(const T &, const self_t &) { \ + return op_<op_##id, op_r, T, self_t>(); \ +} + +#define PYBIND11_INPLACE_OPERATOR(id, op, expr) \ +template <typename B, typename L, typename R> struct op_impl<op_##id, op_l, B, L, R> { \ + static char const* name() { return "__" #id "__"; } \ + static auto execute(L &l, const R &r) -> decltype(expr) { return expr; } \ + static B execute_cast(L &l, const R &r) { return B(expr); } \ +}; \ +template <typename T> op_<op_##id, op_l, self_t, T> op(const self_t &, const T &) { \ + return op_<op_##id, op_l, self_t, T>(); \ +} + +#define PYBIND11_UNARY_OPERATOR(id, op, expr) \ +template <typename B, typename L> struct op_impl<op_##id, op_u, B, L, undefined_t> { \ + static char const* name() { return "__" #id "__"; } \ + static auto execute(const L &l) -> decltype(expr) { return expr; } \ + static B execute_cast(const L &l) { return B(expr); } \ +}; \ +inline op_<op_##id, op_u, self_t, undefined_t> op(const self_t &) { \ + return op_<op_##id, op_u, self_t, undefined_t>(); \ +} + +PYBIND11_BINARY_OPERATOR(sub, rsub, operator-, l - r) +PYBIND11_BINARY_OPERATOR(add, radd, operator+, l + r) +PYBIND11_BINARY_OPERATOR(mul, rmul, operator*, l * r) +#if PY_MAJOR_VERSION >= 3 +PYBIND11_BINARY_OPERATOR(truediv, rtruediv, operator/, l / r) +#else +PYBIND11_BINARY_OPERATOR(div, rdiv, operator/, l / r) +#endif +PYBIND11_BINARY_OPERATOR(mod, rmod, operator%, l % r) +PYBIND11_BINARY_OPERATOR(lshift, rlshift, operator<<, l << r) +PYBIND11_BINARY_OPERATOR(rshift, rrshift, operator>>, l >> r) +PYBIND11_BINARY_OPERATOR(and, rand, operator&, l & r) +PYBIND11_BINARY_OPERATOR(xor, rxor, operator^, l ^ r) +PYBIND11_BINARY_OPERATOR(eq, eq, operator==, l == r) +PYBIND11_BINARY_OPERATOR(ne, ne, operator!=, l != r) +PYBIND11_BINARY_OPERATOR(or, ror, operator|, l | r) +PYBIND11_BINARY_OPERATOR(gt, lt, operator>, l > r) +PYBIND11_BINARY_OPERATOR(ge, le, operator>=, l >= r) +PYBIND11_BINARY_OPERATOR(lt, gt, operator<, l < r) +PYBIND11_BINARY_OPERATOR(le, ge, operator<=, l <= r) +//PYBIND11_BINARY_OPERATOR(pow, rpow, pow, std::pow(l, r)) +PYBIND11_INPLACE_OPERATOR(iadd, operator+=, l += r) +PYBIND11_INPLACE_OPERATOR(isub, operator-=, l -= r) +PYBIND11_INPLACE_OPERATOR(imul, operator*=, l *= r) +PYBIND11_INPLACE_OPERATOR(idiv, operator/=, l /= r) +PYBIND11_INPLACE_OPERATOR(imod, operator%=, l %= r) +PYBIND11_INPLACE_OPERATOR(ilshift, operator<<=, l <<= r) +PYBIND11_INPLACE_OPERATOR(irshift, operator>>=, l >>= r) +PYBIND11_INPLACE_OPERATOR(iand, operator&=, l &= r) +PYBIND11_INPLACE_OPERATOR(ixor, operator^=, l ^= r) +PYBIND11_INPLACE_OPERATOR(ior, operator|=, l |= r) +PYBIND11_UNARY_OPERATOR(neg, operator-, -l) +PYBIND11_UNARY_OPERATOR(pos, operator+, +l) +PYBIND11_UNARY_OPERATOR(abs, abs, std::abs(l)) +PYBIND11_UNARY_OPERATOR(invert, operator~, (~l)) +PYBIND11_UNARY_OPERATOR(bool, operator!, !!l) +PYBIND11_UNARY_OPERATOR(int, int_, (int) l) +PYBIND11_UNARY_OPERATOR(float, float_, (double) l) + +#undef PYBIND11_BINARY_OPERATOR +#undef PYBIND11_INPLACE_OPERATOR +#undef PYBIND11_UNARY_OPERATOR +NAMESPACE_END(detail) + +using detail::self; + +NAMESPACE_END(pybind11) diff --git a/stormpy/resources/pybind11/include/pybind11/pybind11.h b/stormpy/resources/pybind11/include/pybind11/pybind11.h new file mode 100644 index 000000000..22044feeb --- /dev/null +++ b/stormpy/resources/pybind11/include/pybind11/pybind11.h @@ -0,0 +1,1106 @@ +/* + pybind11/pybind11.h: Main header file of the C++11 python + binding generator library + + Copyright (c) 2015 Wenzel Jakob <wenzel@inf.ethz.ch> + + All rights reserved. Use of this source code is governed by a + BSD-style license that can be found in the LICENSE file. +*/ + +#pragma once + +#if defined(_MSC_VER) +# pragma warning(push) +# pragma warning(disable: 4127) // warning C4127: Conditional expression is constant +# pragma warning(disable: 4800) // warning C4800: 'int': forcing value to bool 'true' or 'false' (performance warning) +# pragma warning(disable: 4996) // warning C4996: The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name +# pragma warning(disable: 4100) // warning C4100: Unreferenced formal parameter +# pragma warning(disable: 4512) // warning C4512: Assignment operator was implicitly defined as deleted +#elif defined(__ICC) || defined(__INTEL_COMPILER) +# pragma warning(push) +# pragma warning(disable:2196) // warning #2196: routine is both "inline" and "noinline" +#elif defined(__GNUG__) and !defined(__clang__) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wunused-but-set-parameter" +# pragma GCC diagnostic ignored "-Wunused-but-set-variable" +# pragma GCC diagnostic ignored "-Wmissing-field-initializers" +#endif + +#include "attr.h" + +NAMESPACE_BEGIN(pybind11) + +/// Wraps an arbitrary C++ function/method/lambda function/.. into a callable Python object +class cpp_function : public function { +protected: + /// Picks a suitable return value converter from cast.h + template <typename T> using return_value_caster = + detail::type_caster<typename std::conditional< + std::is_void<T>::value, detail::void_type, typename detail::intrinsic_type<T>::type>::type>; + + /// Picks a suitable argument value converter from cast.h + template <typename... T> using arg_value_caster = + detail::type_caster<typename std::tuple<T...>>; +public: + cpp_function() { } + + /// Vanilla function pointers + template <typename Return, typename... Args, typename... Extra> + cpp_function(Return (*f)(Args...), const Extra&... extra) { + auto rec = new detail::function_record(); + rec->data = (void *) f; + + typedef arg_value_caster<Args...> cast_in; + typedef return_value_caster<Return> cast_out; + + /* Dispatch code which converts function arguments and performs the actual function call */ + rec->impl = [](detail::function_record *rec, handle pyArgs, handle parent) -> handle { + cast_in args; + + /* Try to cast the function arguments into the C++ domain */ + if (!args.load(pyArgs, true)) + return PYBIND11_TRY_NEXT_OVERLOAD; + + /* Invoke call policy pre-call hook */ + detail::process_attributes<Extra...>::precall(pyArgs); + + /* Do the call and convert the return value back into the Python domain */ + handle result = cast_out::cast( + args.template call<Return>((Return (*) (Args...)) rec->data), + rec->policy, parent); + + /* Invoke call policy post-call hook */ + detail::process_attributes<Extra...>::postcall(pyArgs, result); + + return result; + }; + + /* Process any user-provided function attributes */ + detail::process_attributes<Extra...>::init(extra..., rec); + + /* Generate a readable signature describing the function's arguments and return value types */ + using detail::descr; + PYBIND11_DESCR signature = cast_in::name() + detail::_(" -> ") + cast_out::name(); + + /* Register the function with Python from generic (non-templated) code */ + initialize(rec, signature.text(), signature.types(), sizeof...(Args)); + } + + /// Delegating helper constructor to deal with lambda functions + template <typename Func, typename... Extra> cpp_function(Func &&f, const Extra&... extra) { + initialize(std::forward<Func>(f), + (typename detail::remove_class<decltype( + &std::remove_reference<Func>::type::operator())>::type *) nullptr, extra...); + } + + /// Delegating helper constructor to deal with class methods (non-const) + template <typename Return, typename Class, typename... Arg, typename... Extra> cpp_function( + Return (Class::*f)(Arg...), const Extra&... extra) { + initialize([f](Class *c, Arg... args) -> Return { return (c->*f)(args...); }, + (Return (*) (Class *, Arg...)) nullptr, extra...); + } + + /// Delegating helper constructor to deal with class methods (const) + template <typename Return, typename Class, typename... Arg, typename... Extra> cpp_function( + Return (Class::*f)(Arg...) const, const Extra&... extra) { + initialize([f](const Class *c, Arg... args) -> Return { return (c->*f)(args...); }, + (Return (*)(const Class *, Arg ...)) nullptr, extra...); + } + + /// Return the function name + object name() const { return attr("__name__"); } + +protected: + /// Special internal constructor for functors, lambda functions, etc. + template <typename Func, typename Return, typename... Args, typename... Extra> + void initialize(Func &&f, Return (*)(Args...), const Extra&... extra) { + struct capture { typename std::remove_reference<Func>::type f; }; + + /* Store the function including any extra state it might have (e.g. a lambda capture object) */ + auto rec = new detail::function_record(); + rec->data = new capture { std::forward<Func>(f) }; + + /* Create a cleanup handler, but only if we have to (less generated code) */ + if (!std::is_trivially_destructible<Func>::value) + rec->free_data = [](void *ptr) { delete (capture *) ptr; }; + else + rec->free_data = operator delete; + + typedef arg_value_caster<Args...> cast_in; + typedef return_value_caster<Return> cast_out; + + /* Dispatch code which converts function arguments and performs the actual function call */ + rec->impl = [](detail::function_record *rec, handle pyArgs, handle parent) -> handle { + cast_in args; + + /* Try to cast the function arguments into the C++ domain */ + if (!args.load(pyArgs, true)) + return PYBIND11_TRY_NEXT_OVERLOAD; + + /* Invoke call policy pre-call hook */ + detail::process_attributes<Extra...>::precall(pyArgs); + + /* Do the call and convert the return value back into the Python domain */ + handle result = cast_out::cast( + args.template call<Return>(((capture *) rec->data)->f), + rec->policy, parent); + + /* Invoke call policy post-call hook */ + detail::process_attributes<Extra...>::postcall(pyArgs, result); + + return result; + }; + + /* Process any user-provided function attributes */ + detail::process_attributes<Extra...>::init(extra..., rec); + + /* Generate a readable signature describing the function's arguments and return value types */ + using detail::descr; + PYBIND11_DESCR signature = cast_in::name() + detail::_(" -> ") + cast_out::name(); + + /* Register the function with Python from generic (non-templated) code */ + initialize(rec, signature.text(), signature.types(), sizeof...(Args)); + } + + /// Register a function call with Python (generic non-templated code goes here) + void initialize(detail::function_record *rec, const char *text, + const std::type_info *const *types, int args) { + + /* Create copies of all referenced C-style strings */ + rec->name = strdup(rec->name ? rec->name : ""); + if (rec->doc) rec->doc = strdup(rec->doc); + for (auto &a: rec->args) { + if (a.name) + a.name = strdup(a.name); + if (a.descr) + a.descr = strdup(a.descr); + else if (a.value) + a.descr = strdup(((std::string) ((object) handle(a.value).attr("__repr__")).call().str()).c_str()); + } + auto const ®istered_types = detail::get_internals().registered_types_cpp; + + /* Generate a proper function signature */ + std::string signature; + size_t type_depth = 0, char_index = 0, type_index = 0, arg_index = 0; + while (true) { + char c = text[char_index++]; + if (c == '\0') + break; + + if (c == '{') { + if (type_depth == 1 && arg_index < rec->args.size()) { + signature += rec->args[arg_index].name; + signature += " : "; + } + ++type_depth; + } else if (c == '}') { + --type_depth; + if (type_depth == 1 && arg_index < rec->args.size()) { + if (rec->args[arg_index].descr) { + signature += " = "; + signature += rec->args[arg_index].descr; + } + arg_index++; + } + } else if (c == '%') { + const std::type_info *t = types[type_index++]; + if (!t) + pybind11_fail("Internal error while parsing type signature (1)"); + auto it = registered_types.find(std::type_index(*t)); + if (it != registered_types.end()) { + signature += ((const detail::type_info *) it->second)->type->tp_name; + } else { + std::string tname(t->name()); + detail::clean_type_id(tname); + signature += tname; + } + } else { + signature += c; + } + } + if (type_depth != 0 || types[type_index] != nullptr) + pybind11_fail("Internal error while parsing type signature (2)"); + + #if !defined(PYBIND11_CPP14) + delete[] types; + delete[] text; + #endif + +#if PY_MAJOR_VERSION < 3 + if (strcmp(rec->name, "__next__") == 0) { + std::free(rec->name); + rec->name = strdup("next"); + } +#endif + + if (!rec->args.empty() && (int) rec->args.size() != args) + pybind11_fail( + "cpp_function(): function \"" + std::string(rec->name) + "\" takes " + + std::to_string(args) + " arguments, but " + std::to_string(rec->args.size()) + + " pybind11::arg entries were specified!"); + + rec->is_constructor = !strcmp(rec->name, "__init__"); + rec->signature = strdup(signature.c_str()); + rec->args.shrink_to_fit(); + +#if PY_MAJOR_VERSION < 3 + if (rec->sibling && PyMethod_Check(rec->sibling.ptr())) + rec->sibling = PyMethod_GET_FUNCTION(rec->sibling.ptr()); +#endif + + detail::function_record *chain = nullptr, *chain_start = rec; + if (rec->sibling && PyCFunction_Check(rec->sibling.ptr())) { + capsule rec_capsule(PyCFunction_GetSelf(rec->sibling.ptr()), true); + chain = (detail::function_record *) rec_capsule; + /* Never append a method to an overload chain of a parent class; + instead, hide the parent's overloads in this case */ + if (chain->class_ != rec->class_) + chain = nullptr; + } + + if (!chain) { + /* No existing overload was found, create a new function object */ + rec->def = new PyMethodDef(); + memset(rec->def, 0, sizeof(PyMethodDef)); + rec->def->ml_name = rec->name; + rec->def->ml_meth = reinterpret_cast<PyCFunction>(*dispatcher); + rec->def->ml_flags = METH_VARARGS | METH_KEYWORDS; + + capsule rec_capsule(rec, [](PyObject *o) { + destruct((detail::function_record *) PyCapsule_GetPointer(o, nullptr)); + }); + + object scope_module; + if (rec->scope) { + scope_module = (object) rec->scope.attr("__module__"); + if (!scope_module) + scope_module = (object) rec->scope.attr("__name__"); + } + + m_ptr = PyCFunction_NewEx(rec->def, rec_capsule.ptr(), scope_module.ptr()); + if (!m_ptr) + pybind11_fail("cpp_function::cpp_function(): Could not allocate function object"); + } else { + /* Append at the end of the overload chain */ + m_ptr = rec->sibling.ptr(); + inc_ref(); + chain_start = chain; + while (chain->next) + chain = chain->next; + chain->next = rec; + } + + std::string signatures; + int index = 0; + /* Create a nice pydoc rec including all signatures and + docstrings of the functions in the overload chain */ + if (chain) { + // First a generic signature + signatures += rec->name; + signatures += "(*args, **kwargs)\n"; + signatures += "Overloaded function.\n\n"; + } + // Then specific overload signatures + for (auto it = chain_start; it != nullptr; it = it->next) { + if (chain) + signatures += std::to_string(++index) + ". "; + signatures += rec->name; + signatures += it->signature; + signatures += "\n"; + if (it->doc && strlen(it->doc) > 0) { + signatures += "\n"; + signatures += it->doc; + signatures += "\n"; + } + if (it->next) + signatures += "\n"; + } + + /* Install docstring */ + PyCFunctionObject *func = (PyCFunctionObject *) m_ptr; + if (func->m_ml->ml_doc) + std::free((char *) func->m_ml->ml_doc); + func->m_ml->ml_doc = strdup(signatures.c_str()); + + if (rec->class_) { + m_ptr = PYBIND11_INSTANCE_METHOD_NEW(m_ptr, rec->class_.ptr()); + if (!m_ptr) + pybind11_fail("cpp_function::cpp_function(): Could not allocate instance method object"); + Py_DECREF(func); + } + } + + /// When a cpp_function is GCed, release any memory allocated by pybind11 + static void destruct(detail::function_record *rec) { + while (rec) { + detail::function_record *next = rec->next; + if (rec->free_data) + rec->free_data(rec->data); + std::free((char *) rec->name); + std::free((char *) rec->doc); + std::free((char *) rec->signature); + for (auto &arg: rec->args) { + std::free((char *) arg.name); + std::free((char *) arg.descr); + arg.value.dec_ref(); + } + if (rec->def) { + std::free((char *) rec->def->ml_doc); + delete rec->def; + } + delete rec; + rec = next; + } + } + + /// Main dispatch logic for calls to functions bound using pybind11 + static PyObject *dispatcher(PyObject *self, PyObject *args, PyObject *kwargs) { + /* Iterator over the list of potentially admissible overloads */ + detail::function_record *overloads = (detail::function_record *) PyCapsule_GetPointer(self, nullptr), + *it = overloads; + + /* Need to know how many arguments + keyword arguments there are to pick the right overload */ + int nargs = (int) PyTuple_Size(args), + nkwargs = kwargs ? (int) PyDict_Size(kwargs) : 0; + + handle parent = nargs > 0 ? PyTuple_GetItem(args, 0) : nullptr, + result = PYBIND11_TRY_NEXT_OVERLOAD; + try { + for (; it != nullptr; it = it->next) { + tuple args_(args, true); + int kwargs_consumed = 0; + + /* For each overload: + 1. If the required list of arguments is longer than the + actually provided amount, create a copy of the argument + list and fill in any available keyword/default arguments. + 2. Ensure that all keyword arguments were "consumed" + 3. Call the function call dispatcher (function_record::impl) + */ + + if (nargs < (int) it->args.size()) { + args_ = tuple(it->args.size()); + for (int i = 0; i < nargs; ++i) { + handle item = PyTuple_GET_ITEM(args, i); + PyTuple_SET_ITEM(args_.ptr(), i, item.inc_ref().ptr()); + } + + int arg_ctr = 0; + for (auto const &it2 : it->args) { + int index = arg_ctr++; + if (PyTuple_GET_ITEM(args_.ptr(), index)) + continue; + + handle value; + if (kwargs) + value = PyDict_GetItemString(kwargs, it2.name); + + if (value) + kwargs_consumed++; + else if (it2.value) + value = it2.value; + + if (value) { + PyTuple_SET_ITEM(args_.ptr(), index, value.inc_ref().ptr()); + } else { + kwargs_consumed = -1; /* definite failure */ + break; + } + } + } + + if (kwargs_consumed == nkwargs) + result = it->impl(it, args_, parent); + + if (result.ptr() != PYBIND11_TRY_NEXT_OVERLOAD) + break; + } + } catch (const error_already_set &) { return nullptr; + } catch (const index_error &e) { PyErr_SetString(PyExc_IndexError, e.what()); return nullptr; + } catch (const stop_iteration &e) { PyErr_SetString(PyExc_StopIteration, e.what()); return nullptr; + } catch (const std::bad_alloc &e) { PyErr_SetString(PyExc_MemoryError, e.what()); return nullptr; + } catch (const std::domain_error &e) { PyErr_SetString(PyExc_ValueError, e.what()); return nullptr; + } catch (const std::invalid_argument &e) { PyErr_SetString(PyExc_ValueError, e.what()); return nullptr; + } catch (const std::length_error &e) { PyErr_SetString(PyExc_ValueError, e.what()); return nullptr; + } catch (const std::out_of_range &e) { PyErr_SetString(PyExc_IndexError, e.what()); return nullptr; + } catch (const std::range_error &e) { PyErr_SetString(PyExc_ValueError, e.what()); return nullptr; + } catch (const std::exception &e) { PyErr_SetString(PyExc_RuntimeError, e.what()); return nullptr; + } catch (...) { + PyErr_SetString(PyExc_RuntimeError, "Caught an unknown exception!"); + return nullptr; + } + + if (result.ptr() == PYBIND11_TRY_NEXT_OVERLOAD) { + std::string msg = "Incompatible function arguments. The " + "following argument types are supported:\n"; + int ctr = 0; + for (detail::function_record *it2 = overloads; it2 != nullptr; it2 = it2->next) { + msg += " "+ std::to_string(++ctr) + ". "; + msg += it2->signature; + msg += "\n"; + } + PyErr_SetString(PyExc_TypeError, msg.c_str()); + return nullptr; + } else if (!result) { + std::string msg = "Unable to convert function return value to a " + "Python type! The signature was\n\t"; + msg += it->signature; + PyErr_SetString(PyExc_TypeError, msg.c_str()); + return nullptr; + } else { + if (overloads->is_constructor) { + /* When a construtor ran successfully, the corresponding + holder type (e.g. std::unique_ptr) must still be initialized. */ + PyObject *inst = PyTuple_GetItem(args, 0); + auto tinfo = detail::get_type_info(Py_TYPE(inst)); + tinfo->init_holder(inst, nullptr); + } + return result.ptr(); + } + } +}; + +/// Wrapper for Python extension modules +class module : public object { +public: + PYBIND11_OBJECT_DEFAULT(module, object, PyModule_Check) + + module(const char *name, const char *doc = nullptr) { +#if PY_MAJOR_VERSION >= 3 + PyModuleDef *def = new PyModuleDef(); + memset(def, 0, sizeof(PyModuleDef)); + def->m_name = name; + def->m_doc = doc; + def->m_size = -1; + Py_INCREF(def); + m_ptr = PyModule_Create(def); +#else + m_ptr = Py_InitModule3(name, nullptr, doc); +#endif + if (m_ptr == nullptr) + pybind11_fail("Internal error in module::module()"); + inc_ref(); + } + + template <typename Func, typename... Extra> + module &def(const char *name_, Func &&f, const Extra& ... extra) { + cpp_function func(std::forward<Func>(f), name(name_), + sibling((handle) attr(name_)), scope(*this), extra...); + /* PyModule_AddObject steals a reference to 'func' */ + PyModule_AddObject(ptr(), name_, func.inc_ref().ptr()); + return *this; + } + + module def_submodule(const char *name, const char *doc = nullptr) { + std::string full_name = std::string(PyModule_GetName(m_ptr)) + + std::string(".") + std::string(name); + module result(PyImport_AddModule(full_name.c_str()), true); + if (doc) + result.attr("__doc__") = pybind11::str(doc); + attr(name) = result; + return result; + } + + static module import(const char *name) { + PyObject *obj = PyImport_ImportModule(name); + if (!obj) + pybind11_fail("Module \"" + std::string(name) + "\" not found!"); + return module(obj, false); + } +}; + +NAMESPACE_BEGIN(detail) +/// Generic support for creating new Python heap types +class generic_type : public object { + template <typename type, typename holder_type> friend class class_; +public: + PYBIND11_OBJECT_DEFAULT(generic_type, object, PyType_Check) +protected: + void initialize(type_record *rec) { + if (rec->base_type) { + if (rec->base_handle) + pybind11_fail("generic_type: specified base type multiple times!"); + rec->base_handle = detail::get_type_handle(*(rec->base_type)); + if (!rec->base_handle) { + std::string tname(rec->base_type->name()); + detail::clean_type_id(tname); + pybind11_fail("generic_type: type \"" + std::string(rec->name) + + "\" referenced unknown base type \"" + tname + "\""); + } + } + + object type_holder(PyType_Type.tp_alloc(&PyType_Type, 0), false); + object name(PYBIND11_FROM_STRING(rec->name), false); + auto type = (PyHeapTypeObject*) type_holder.ptr(); + + if (!type_holder || !name) + pybind11_fail("generic_type: unable to create type object!"); + + /* Register supplemental type information in C++ dict */ + auto &internals = get_internals(); + detail::type_info *tinfo = new detail::type_info(); + tinfo->type = (PyTypeObject *) type; + tinfo->type_size = rec->type_size; + tinfo->init_holder = rec->init_holder; + internals.registered_types_cpp[std::type_index(*(rec->type))] = tinfo; + internals.registered_types_py[type] = tinfo; + + object scope_module; + if (rec->scope) { + scope_module = (object) rec->scope.attr("__module__"); + if (!scope_module) + scope_module = (object) rec->scope.attr("__name__"); + } + + std::string full_name = (scope_module ? ((std::string) scope_module.str() + "." + rec->name) + : std::string(rec->name)); + /* Basic type attributes */ + type->ht_type.tp_name = strdup(full_name.c_str()); + type->ht_type.tp_basicsize = rec->instance_size; + type->ht_type.tp_base = (PyTypeObject *) rec->base_handle.ptr(); + rec->base_handle.inc_ref(); + +#if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 3 + /* Qualified names for Python >= 3.3 */ + object scope_qualname; + if (rec->scope) + scope_qualname = (object) rec->scope.attr("__qualname__"); + if (scope_qualname) { + type->ht_qualname = PyUnicode_FromFormat( + "%U.%U", scope_qualname.ptr(), name.ptr()); + } else { + type->ht_qualname = name.ptr(); + name.inc_ref(); + } +#endif + type->ht_name = name.release().ptr(); + + /* Supported protocols */ + type->ht_type.tp_as_number = &type->as_number; + type->ht_type.tp_as_sequence = &type->as_sequence; + type->ht_type.tp_as_mapping = &type->as_mapping; + + /* Supported elementary operations */ + type->ht_type.tp_init = (initproc) init; + type->ht_type.tp_new = (newfunc) new_instance; + type->ht_type.tp_dealloc = rec->dealloc; + + /* Support weak references (needed for the keep_alive feature) */ + type->ht_type.tp_weaklistoffset = offsetof(instance_essentials<void>, weakrefs); + + /* Flags */ + type->ht_type.tp_flags |= Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HEAPTYPE; +#if PY_MAJOR_VERSION < 3 + type->ht_type.tp_flags |= Py_TPFLAGS_CHECKTYPES; +#endif + type->ht_type.tp_flags &= ~Py_TPFLAGS_HAVE_GC; + + if (rec->doc) { + /* Allocate memory for docstring (using PyObject_MALLOC, since + Python will free this later on) */ + size_t size = strlen(rec->doc) + 1; + type->ht_type.tp_doc = (char *) PyObject_MALLOC(size); + memcpy((void *) type->ht_type.tp_doc, rec->doc, size); + } + + if (PyType_Ready(&type->ht_type) < 0) + pybind11_fail("generic_type: PyType_Ready failed!"); + + m_ptr = type_holder.ptr(); + + if (scope_module) // Needed by pydoc + attr("__module__") = scope_module; + + /* Register type with the parent scope */ + if (rec->scope) + rec->scope.attr(handle(type->ht_name)) = *this; + + type_holder.release(); + } + + /// Allocate a metaclass on demand (for static properties) + handle metaclass() { + auto &ht_type = ((PyHeapTypeObject *) m_ptr)->ht_type; + auto &ob_type = PYBIND11_OB_TYPE(ht_type); + + if (ob_type == &PyType_Type) { + std::string name_ = std::string(ht_type.tp_name) + "__Meta"; + object type_holder(PyType_Type.tp_alloc(&PyType_Type, 0), false); + object name(PYBIND11_FROM_STRING(name_.c_str()), false); + if (!type_holder || !name) + pybind11_fail("generic_type::metaclass(): unable to create type object!"); + + auto type = (PyHeapTypeObject*) type_holder.ptr(); + type->ht_name = name.release().ptr(); +#if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 3 + /* Qualified names for Python >= 3.3 */ + type->ht_qualname = PyUnicode_FromFormat( + "%U__Meta", ((object) attr("__qualname__")).ptr()); +#endif + type->ht_type.tp_name = strdup(name_.c_str()); + type->ht_type.tp_base = ob_type; + type->ht_type.tp_flags |= (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HEAPTYPE) & + ~Py_TPFLAGS_HAVE_GC; + + if (PyType_Ready(&type->ht_type) < 0) + pybind11_fail("generic_type::metaclass(): PyType_Ready failed!"); + + ob_type = (PyTypeObject *) type_holder.release().ptr(); + } + return handle((PyObject *) ob_type); + } + + static int init(void *self, PyObject *, PyObject *) { + std::string msg = std::string(Py_TYPE(self)->tp_name) + ": No constructor defined!"; + PyErr_SetString(PyExc_TypeError, msg.c_str()); + return -1; + } + + static PyObject *new_instance(PyTypeObject *type, PyObject *, PyObject *) { + instance<void> *self = (instance<void> *) PyType_GenericAlloc((PyTypeObject *) type, 0); + auto tinfo = detail::get_type_info(type); + self->value = ::operator new(tinfo->type_size); + self->owned = true; + self->parent = nullptr; + self->constructed = false; + detail::get_internals().registered_instances[self->value] = (PyObject *) self; + return (PyObject *) self; + } + + static void dealloc(instance<void> *self) { + if (self->value) { + bool dont_cache = self->parent && ((instance<void> *) self->parent)->value == self->value; + if (!dont_cache) { // avoid an issue with internal references matching their parent's address + auto ®istered_instances = detail::get_internals().registered_instances; + auto it = registered_instances.find(self->value); + if (it == registered_instances.end()) + pybind11_fail("generic_type::dealloc(): Tried to deallocate unregistered instance!"); + registered_instances.erase(it); + } + Py_XDECREF(self->parent); + if (self->weakrefs) + PyObject_ClearWeakRefs((PyObject *) self); + } + Py_TYPE(self)->tp_free((PyObject*) self); + } + + void install_buffer_funcs( + buffer_info *(*get_buffer)(PyObject *, void *), + void *get_buffer_data) { + PyHeapTypeObject *type = (PyHeapTypeObject*) m_ptr; + type->ht_type.tp_as_buffer = &type->as_buffer; +#if PY_MAJOR_VERSION < 3 + type->ht_type.tp_flags |= Py_TPFLAGS_HAVE_NEWBUFFER; +#endif + type->as_buffer.bf_getbuffer = getbuffer; + type->as_buffer.bf_releasebuffer = releasebuffer; + auto tinfo = detail::get_type_info(&type->ht_type); + tinfo->get_buffer = get_buffer; + tinfo->get_buffer_data = get_buffer_data; + } + + static int getbuffer(PyObject *obj, Py_buffer *view, int flags) { + auto tinfo = detail::get_type_info(Py_TYPE(obj)); + if (view == nullptr || obj == nullptr || !tinfo || !tinfo->get_buffer) { + PyErr_SetString(PyExc_BufferError, "generic_type::getbuffer(): Internal error"); + return -1; + } + memset(view, 0, sizeof(Py_buffer)); + buffer_info *info = tinfo->get_buffer(obj, tinfo->get_buffer_data); + view->obj = obj; + view->ndim = 1; + view->internal = info; + view->buf = info->ptr; + view->itemsize = info->itemsize; + view->len = view->itemsize; + for (auto s : info->shape) + view->len *= s; + if ((flags & PyBUF_FORMAT) == PyBUF_FORMAT) + view->format = const_cast<char *>(info->format.c_str()); + if ((flags & PyBUF_STRIDES) == PyBUF_STRIDES) { + view->ndim = info->ndim; + view->strides = (ssize_t *) &info->strides[0]; + view->shape = (ssize_t *) &info->shape[0]; + } + Py_INCREF(view->obj); + return 0; + } + + static void releasebuffer(PyObject *, Py_buffer *view) { delete (buffer_info *) view->internal; } +}; +NAMESPACE_END(detail) + +template <typename type, typename holder_type = std::unique_ptr<type>> +class class_ : public detail::generic_type { +public: + typedef detail::instance<type, holder_type> instance_type; + + PYBIND11_OBJECT(class_, detail::generic_type, PyType_Check) + + template <typename... Extra> + class_(handle scope, const char *name, const Extra &... extra) { + detail::type_record record; + record.scope = scope; + record.name = name; + record.type = &typeid(type); + record.type_size = sizeof(type); + record.instance_size = sizeof(instance_type); + record.init_holder = init_holder; + record.dealloc = dealloc; + + /* Process optional arguments, if any */ + detail::process_attributes<Extra...>::init(extra..., &record); + + detail::generic_type::initialize(&record); + } + + template <typename Func, typename... Extra> + class_ &def(const char *name_, Func&& f, const Extra&... extra) { + cpp_function cf(std::forward<Func>(f), name(name_), + sibling(attr(name_)), is_method(*this), + extra...); + attr(cf.name()) = cf; + return *this; + } + + template <typename Func, typename... Extra> class_ & + def_static(const char *name_, Func f, const Extra&... extra) { + cpp_function cf(std::forward<Func>(f), name(name_), + sibling(attr(name_)), scope(*this), extra...); + attr(cf.name()) = cf; + return *this; + } + + template <detail::op_id id, detail::op_type ot, typename L, typename R, typename... Extra> + class_ &def(const detail::op_<id, ot, L, R> &op, const Extra&... extra) { + op.template execute<type>(*this, extra...); + return *this; + } + + template <detail::op_id id, detail::op_type ot, typename L, typename R, typename... Extra> + class_ & def_cast(const detail::op_<id, ot, L, R> &op, const Extra&... extra) { + op.template execute_cast<type>(*this, extra...); + return *this; + } + + template <typename... Args, typename... Extra> + class_ &def(const detail::init<Args...> &init, const Extra&... extra) { + init.template execute<type>(*this, extra...); + return *this; + } + + template <typename Func> class_& def_buffer(Func &&func) { + struct capture { Func func; }; + capture *ptr = new capture { std::forward<Func>(func) }; + install_buffer_funcs([](PyObject *obj, void *ptr) -> buffer_info* { + detail::type_caster<type> caster; + if (!caster.load(obj, false)) + return nullptr; + return new buffer_info(((capture *) ptr)->func(caster)); + }, ptr); + return *this; + } + + template <typename C, typename D, typename... Extra> + class_ &def_readwrite(const char *name, D C::*pm, const Extra&... extra) { + cpp_function fget([pm](const C &c) -> const D &{ return c.*pm; }, is_method(*this)), + fset([pm](C &c, const D &value) { c.*pm = value; }, is_method(*this)); + def_property(name, fget, fset, return_value_policy::reference_internal, extra...); + return *this; + } + + template <typename C, typename D, typename... Extra> + class_ &def_readonly(const char *name, const D C::*pm, const Extra& ...extra) { + cpp_function fget([pm](const C &c) -> const D &{ return c.*pm; }, is_method(*this)); + def_property_readonly(name, fget, return_value_policy::reference_internal, extra...); + return *this; + } + + template <typename D, typename... Extra> + class_ &def_readwrite_static(const char *name, D *pm, const Extra& ...extra) { + cpp_function fget([pm](object) -> const D &{ return *pm; }, scope(*this)), + fset([pm](object, const D &value) { *pm = value; }, scope(*this)); + def_property_static(name, fget, fset, return_value_policy::reference, extra...); + return *this; + } + + template <typename D, typename... Extra> + class_ &def_readonly_static(const char *name, const D *pm, const Extra& ...extra) { + cpp_function fget([pm](object) -> const D &{ return *pm; }, scope(*this)); + def_property_readonly_static(name, fget, return_value_policy::reference, extra...); + return *this; + } + + template <typename... Extra> + class_ &def_property_readonly(const char *name, const cpp_function &fget, const Extra& ...extra) { + def_property(name, fget, cpp_function(), extra...); + return *this; + } + + template <typename... Extra> + class_ &def_property_readonly_static(const char *name, const cpp_function &fget, const Extra& ...extra) { + def_property_static(name, fget, cpp_function(), extra...); + return *this; + } + + template <typename... Extra> + class_ &def_property(const char *name, const cpp_function &fget, const cpp_function &fset, const Extra& ...extra) { + return def_property_static(name, fget, fset, is_method(*this), extra...); + } + + template <typename... Extra> + class_ &def_property_static(const char *name, const cpp_function &fget, const cpp_function &fset, const Extra& ...extra) { + auto rec_fget = get_function_record(fget), rec_fset = get_function_record(fset); + detail::process_attributes<Extra...>::init(extra..., rec_fget); + if (rec_fset) + detail::process_attributes<Extra...>::init(extra..., rec_fset); + pybind11::str doc_obj = pybind11::str(rec_fget->doc ? rec_fget->doc : ""); + object property( + PyObject_CallFunctionObjArgs((PyObject *) &PyProperty_Type, fget.ptr() ? fget.ptr() : Py_None, + fset.ptr() ? fset.ptr() : Py_None, Py_None, doc_obj.ptr(), nullptr), false); + if (rec_fget->class_) + attr(name) = property; + else + metaclass().attr(name) = property; + return *this; + } + + template <typename target> class_ alias() { + auto &instances = pybind11::detail::get_internals().registered_types_cpp; + instances[std::type_index(typeid(target))] = instances[std::type_index(typeid(type))]; + return *this; + } +private: + /// Initialize holder object, variant 1: object derives from enable_shared_from_this + template <typename T> + static void init_holder_helper(instance_type *inst, const holder_type * /* unused */, const std::enable_shared_from_this<T> * /* dummy */) { + try { + new (&inst->holder) holder_type(std::static_pointer_cast<type>(inst->value->shared_from_this())); + } catch (const std::bad_weak_ptr &) { + new (&inst->holder) holder_type(inst->value); + } + } + + /// Initialize holder object, variant 2: try to construct from existing holder object, if possible + template <typename T = holder_type, + typename std::enable_if<std::is_copy_constructible<T>::value, int>::type = 0> + static void init_holder_helper(instance_type *inst, const holder_type *holder_ptr, const void * /* dummy */) { + if (holder_ptr) + new (&inst->holder) holder_type(*holder_ptr); + else + new (&inst->holder) holder_type(inst->value); + } + + /// Initialize holder object, variant 3: holder is not copy constructible (e.g. unique_ptr), always initialize from raw pointer + template <typename T = holder_type, + typename std::enable_if<!std::is_copy_constructible<T>::value, int>::type = 0> + static void init_holder_helper(instance_type *inst, const holder_type * /* unused */, const void * /* dummy */) { + new (&inst->holder) holder_type(inst->value); + } + + /// Initialize holder object of an instance, possibly given a pointer to an existing holder + static void init_holder(PyObject *inst_, const void *holder_ptr) { + auto inst = (instance_type *) inst_; + init_holder_helper(inst, (const holder_type *) holder_ptr, inst->value); + inst->constructed = true; + } + + static void dealloc(PyObject *inst_) { + instance_type *inst = (instance_type *) inst_; + if (inst->owned) { + if (inst->constructed) + inst->holder.~holder_type(); + else + ::operator delete(inst->value); + } + generic_type::dealloc((detail::instance<void> *) inst); + } + + static detail::function_record *get_function_record(handle h) { + h = detail::get_function(h); + return h ? (detail::function_record *) capsule( + PyCFunction_GetSelf(h.ptr()), true) : nullptr; + } +}; + +/// Binds C++ enumerations and enumeration classes to Python +template <typename Type> class enum_ : public class_<Type> { +public: + template <typename... Extra> + enum_(const handle &scope, const char *name, const Extra&... extra) + : class_<Type>(scope, name, extra...), m_parent(scope) { + auto entries = new std::unordered_map<int, const char *>(); + this->def("__repr__", [name, entries](Type value) -> std::string { + auto it = entries->find((int) value); + return std::string(name) + "." + + ((it == entries->end()) ? std::string("???") + : std::string(it->second)); + }); + this->def("__init__", [](Type& value, int i) { value = (Type) i; }); + this->def("__int__", [](Type value) { return (int) value; }); + this->def("__eq__", [](const Type &value, Type value2) { return value == value2; }); + this->def("__ne__", [](const Type &value, Type value2) { return value != value2; }); + this->def("__hash__", [](const Type &value) { return (int) value; }); + m_entries = entries; + } + + /// Export enumeration entries into the parent scope + void export_values() { + PyObject *dict = ((PyTypeObject *) this->m_ptr)->tp_dict; + PyObject *key, *value; + ssize_t pos = 0; + while (PyDict_Next(dict, &pos, &key, &value)) + if (PyObject_IsInstance(value, this->m_ptr)) + m_parent.attr(key) = value; + } + + /// Add an enumeration entry + enum_& value(char const* name, Type value) { + this->attr(name) = pybind11::cast(value, return_value_policy::copy); + (*m_entries)[(int) value] = name; + return *this; + } +private: + std::unordered_map<int, const char *> *m_entries; + handle m_parent; +}; + +NAMESPACE_BEGIN(detail) +template <typename... Args> struct init { + template <typename Base, typename Holder, typename... Extra> void execute(pybind11::class_<Base, Holder> &class_, const Extra&... extra) const { + /// Function which calls a specific C++ in-place constructor + class_.def("__init__", [](Base *instance, Args... args) { new (instance) Base(args...); }, extra...); + } +}; + +PYBIND11_NOINLINE inline void keep_alive_impl(int Nurse, int Patient, handle args, handle ret) { + /* Clever approach based on weak references taken from Boost.Python */ + handle nurse (Nurse > 0 ? PyTuple_GetItem(args.ptr(), Nurse - 1) : ret.ptr()); + handle patient(Patient > 0 ? PyTuple_GetItem(args.ptr(), Patient - 1) : ret.ptr()); + + if (!nurse || !patient) + pybind11_fail("Could not activate keep_alive!"); + + cpp_function disable_lifesupport( + [patient](handle weakref) { patient.dec_ref(); weakref.dec_ref(); }); + + weakref wr(nurse, disable_lifesupport); + + patient.inc_ref(); /* reference patient and leak the weak reference */ + (void) wr.release(); +} + +template <typename Iterator> struct iterator_state { Iterator it, end; }; + +NAMESPACE_END(detail) + +template <typename... Args> detail::init<Args...> init() { return detail::init<Args...>(); } + +template <typename Iterator, typename... Extra> iterator make_iterator(Iterator first, Iterator last, Extra&&... extra) { + typedef detail::iterator_state<Iterator> state; + + if (!detail::get_type_info(typeid(state))) { + class_<state>(handle(), "") + .def("__iter__", [](state &s) -> state& { return s; }) + .def("__next__", [](state &s) -> decltype(*std::declval<Iterator>()) & { + if (s.it == s.end) + throw stop_iteration(); + return *s.it++; + }, return_value_policy::reference_internal, std::forward<Extra>(extra)...); + } + + return (iterator) cast(state { first, last }); +} + +template <typename InputType, typename OutputType> void implicitly_convertible() { + auto implicit_caster = [](PyObject *obj, PyTypeObject *type) -> PyObject * { + if (!detail::type_caster<InputType>().load(obj, false)) + return nullptr; + tuple args(1); + args[0] = obj; + PyObject *result = PyObject_Call((PyObject *) type, args.ptr(), nullptr); + if (result == nullptr) + PyErr_Clear(); + return result; + }; + auto ®istered_types = detail::get_internals().registered_types_cpp; + auto it = registered_types.find(std::type_index(typeid(OutputType))); + if (it == registered_types.end()) + pybind11_fail("implicitly_convertible: Unable to find type " + type_id<OutputType>()); + ((detail::type_info *) it->second)->implicit_conversions.push_back(implicit_caster); +} + +#if defined(WITH_THREAD) +inline void init_threading() { PyEval_InitThreads(); } + +class gil_scoped_acquire { + PyGILState_STATE state; +public: + inline gil_scoped_acquire() { state = PyGILState_Ensure(); } + inline ~gil_scoped_acquire() { PyGILState_Release(state); } +}; + +class gil_scoped_release { + PyThreadState *state; +public: + inline gil_scoped_release() { state = PyEval_SaveThread(); } + inline ~gil_scoped_release() { PyEval_RestoreThread(state); } +}; +#endif + +inline function get_overload(const void *this_ptr, const char *name) { + handle py_object = detail::get_object_handle(this_ptr); + if (!py_object) + return function(); + handle type = py_object.get_type(); + auto key = std::make_pair(type.ptr(), name); + + /* Cache functions that aren't overloaded in Python to avoid + many costly Python dictionary lookups below */ + auto &cache = detail::get_internals().inactive_overload_cache; + if (cache.find(key) != cache.end()) + return function(); + + function overload = (function) py_object.attr(name); + if (overload.is_cpp_function()) { + cache.insert(key); + return function(); + } + + /* Don't call dispatch code if invoked from overridden function */ + PyFrameObject *frame = PyThreadState_Get()->frame; + if (frame && (std::string) pybind11::handle(frame->f_code->co_name).str() == name && + frame->f_code->co_argcount > 0) { + PyFrame_FastToLocals(frame); + PyObject *self_caller = PyDict_GetItem( + frame->f_locals, PyTuple_GET_ITEM(frame->f_code->co_varnames, 0)); + if (self_caller == py_object.ptr()) + return function(); + } + return overload; +} + +#define PYBIND11_OVERLOAD_INT(ret_type, class_name, name, ...) { \ + pybind11::gil_scoped_acquire gil; \ + pybind11::function overload = pybind11::get_overload(this, #name); \ + if (overload) \ + return overload.call(__VA_ARGS__).template cast<ret_type>(); } + +#define PYBIND11_OVERLOAD(ret_type, class_name, name, ...) \ + PYBIND11_OVERLOAD_INT(ret_type, class_name, name, __VA_ARGS__) \ + return class_name::name(__VA_ARGS__) + +#define PYBIND11_OVERLOAD_PURE(ret_type, class_name, name, ...) \ + PYBIND11_OVERLOAD_INT(ret_type, class_name, name, __VA_ARGS__) \ + pybind11::pybind11_fail("Tried to call pure virtual function \"" #name "\""); + +NAMESPACE_END(pybind11) + +#if defined(_MSC_VER) +# pragma warning(pop) +#elif defined(__ICC) || defined(__INTEL_COMPILER) +# pragma warning(pop) +#elif defined(__GNUG__) and !defined(__clang__) +# pragma GCC diagnostic pop +#endif diff --git a/stormpy/resources/pybind11/include/pybind11/pytypes.h b/stormpy/resources/pybind11/include/pybind11/pytypes.h new file mode 100644 index 000000000..c7f109cdc --- /dev/null +++ b/stormpy/resources/pybind11/include/pybind11/pytypes.h @@ -0,0 +1,476 @@ +/* + pybind11/typeid.h: Convenience wrapper classes for basic Python types + + Copyright (c) 2015 Wenzel Jakob <wenzel@inf.ethz.ch> + + All rights reserved. Use of this source code is governed by a + BSD-style license that can be found in the LICENSE file. +*/ + +#pragma once + +#include "common.h" +#include <utility> +#include <type_traits> + +NAMESPACE_BEGIN(pybind11) + +/* A few forward declarations */ +class object; +class str; +class object; +class dict; +class iterator; +namespace detail { class accessor; } + +/// Holds a reference to a Python object (no reference counting) +class handle { +public: + handle() : m_ptr(nullptr) { } + handle(const handle &other) : m_ptr(other.m_ptr) { } + handle(PyObject *ptr) : m_ptr(ptr) { } + PyObject *ptr() const { return m_ptr; } + PyObject *&ptr() { return m_ptr; } + const handle& inc_ref() const { Py_XINCREF(m_ptr); return *this; } + const handle& dec_ref() const { Py_XDECREF(m_ptr); return *this; } + int ref_count() const { return (int) Py_REFCNT(m_ptr); } + handle get_type() const { return handle((PyObject *) Py_TYPE(m_ptr)); } + inline iterator begin() const; + inline iterator end() const; + inline detail::accessor operator[](handle key) const; + inline detail::accessor operator[](const char *key) const; + inline detail::accessor attr(handle key) const; + inline detail::accessor attr(const char *key) const; + inline pybind11::str str() const; + template <typename T> T cast() const; + template <typename ... Args> object call(Args&&... args_) const; + operator bool() const { return m_ptr != nullptr; } + bool operator==(const handle &h) const { return m_ptr == h.m_ptr; } + bool operator!=(const handle &h) const { return m_ptr != h.m_ptr; } + bool check() const { return m_ptr != nullptr; } +protected: + PyObject *m_ptr; +}; + +/// Holds a reference to a Python object (with reference counting) +class object : public handle { +public: + object() { } + object(const object &o) : handle(o) { inc_ref(); } + object(const handle &h, bool borrowed) : handle(h) { if (borrowed) inc_ref(); } + object(PyObject *ptr, bool borrowed) : handle(ptr) { if (borrowed) inc_ref(); } + object(object &&other) { m_ptr = other.m_ptr; other.m_ptr = nullptr; } + ~object() { dec_ref(); } + + handle release() { + PyObject *tmp = m_ptr; + m_ptr = nullptr; + return handle(tmp); + } + + object& operator=(object &other) { + other.inc_ref(); + dec_ref(); + m_ptr = other.m_ptr; + return *this; + } + + object& operator=(object &&other) { + if (this != &other) { + handle temp(m_ptr); + m_ptr = other.m_ptr; + other.m_ptr = nullptr; + temp.dec_ref(); + } + return *this; + } +}; + +NAMESPACE_BEGIN(detail) +inline handle get_function(handle value) { + if (value) { +#if PY_MAJOR_VERSION >= 3 + if (PyInstanceMethod_Check(value.ptr())) + value = PyInstanceMethod_GET_FUNCTION(value.ptr()); +#endif + if (PyMethod_Check(value.ptr())) + value = PyMethod_GET_FUNCTION(value.ptr()); + } + return value; +} + +class accessor { +public: + accessor(handle obj, handle key, bool attr) + : obj(obj), key(key, true), attr(attr) { } + accessor(handle obj, const char *key, bool attr) + : obj(obj), key(PyUnicode_FromString(key), false), attr(attr) { } + accessor(const accessor &a) : obj(a.obj), key(a.key), attr(a.attr) { } + + void operator=(accessor o) { operator=(object(o)); } + + void operator=(const handle &value) { + if (attr) { + if (PyObject_SetAttr(obj.ptr(), key.ptr(), value.ptr()) == -1) + pybind11_fail("Unable to set object attribute"); + } else { + if (PyObject_SetItem(obj.ptr(), key.ptr(), value.ptr()) == -1) + pybind11_fail("Unable to set object item"); + } + } + + operator object() const { + object result(attr ? PyObject_GetAttr(obj.ptr(), key.ptr()) + : PyObject_GetItem(obj.ptr(), key.ptr()), false); + if (!result) {PyErr_Clear(); } + return result; + } + + template <typename T> inline T cast() const { return operator object().cast<T>(); } + + operator bool() const { + if (attr) { + return (bool) PyObject_HasAttr(obj.ptr(), key.ptr()); + } else { + object result(PyObject_GetItem(obj.ptr(), key.ptr()), false); + if (!result) PyErr_Clear(); + return (bool) result; + } + }; + +private: + handle obj; + object key; + bool attr; +}; + +struct list_accessor { +public: + list_accessor(handle list, size_t index) : list(list), index(index) { } + + void operator=(list_accessor o) { return operator=(object(o)); } + + void operator=(const handle &o) { + // PyList_SetItem steals a reference to 'o' + if (PyList_SetItem(list.ptr(), (ssize_t) index, o.inc_ref().ptr()) < 0) + pybind11_fail("Unable to assign value in Python list!"); + } + + operator object() const { + PyObject *result = PyList_GetItem(list.ptr(), (ssize_t) index); + if (!result) + pybind11_fail("Unable to retrieve value from Python list!"); + return object(result, true); + } + + template <typename T> inline T cast() const { return operator object().cast<T>(); } +private: + handle list; + size_t index; +}; + +struct tuple_accessor { +public: + tuple_accessor(handle tuple, size_t index) : tuple(tuple), index(index) { } + + void operator=(tuple_accessor o) { return operator=(object(o)); } + + void operator=(const handle &o) { + // PyTuple_SetItem steals a referenceto 'o' + if (PyTuple_SetItem(tuple.ptr(), (ssize_t) index, o.inc_ref().ptr()) < 0) + pybind11_fail("Unable to assign value in Python tuple!"); + } + + operator object() const { + PyObject *result = PyTuple_GetItem(tuple.ptr(), (ssize_t) index); + if (!result) + pybind11_fail("Unable to retrieve value from Python tuple!"); + return object(result, true); + } + + template <typename T> inline T cast() const { return operator object().cast<T>(); } +private: + handle tuple; + size_t index; +}; + +struct dict_iterator { +public: + dict_iterator(handle dict = handle(), ssize_t pos = -1) : dict(dict), pos(pos) { } + dict_iterator& operator++() { + if (!PyDict_Next(dict.ptr(), &pos, &key.ptr(), &value.ptr())) + pos = -1; + return *this; + } + std::pair<handle, handle> operator*() const { + return std::make_pair(key, value); + } + bool operator==(const dict_iterator &it) const { return it.pos == pos; } + bool operator!=(const dict_iterator &it) const { return it.pos != pos; } +private: + handle dict, key, value; + ssize_t pos = 0; +}; + +NAMESPACE_END(detail) + + +#define PYBIND11_OBJECT_CVT(Name, Parent, CheckFun, CvtStmt) \ + Name(const handle &h, bool borrowed) : Parent(h, borrowed) { CvtStmt; } \ + Name(const object& o): Parent(o) { CvtStmt; } \ + Name(object&& o): Parent(std::move(o)) { CvtStmt; } \ + Name& operator=(object&& o) { (void) static_cast<Name&>(object::operator=(std::move(o))); CvtStmt; return *this; } \ + Name& operator=(object& o) { return static_cast<Name&>(object::operator=(o)); CvtStmt; } \ + bool check() const { return m_ptr != nullptr && (bool) CheckFun(m_ptr); } + +#define PYBIND11_OBJECT(Name, Parent, CheckFun) \ + PYBIND11_OBJECT_CVT(Name, Parent, CheckFun, ) + +#define PYBIND11_OBJECT_DEFAULT(Name, Parent, CheckFun) \ + PYBIND11_OBJECT(Name, Parent, CheckFun) \ + Name() : Parent() { } + +class iterator : public object { +public: + PYBIND11_OBJECT_DEFAULT(iterator, object, PyIter_Check) + iterator(handle obj, bool borrowed = false) : object(obj, borrowed) { } + iterator& operator++() { + if (ptr()) + value = object(PyIter_Next(m_ptr), false); + return *this; + } + bool operator==(const iterator &it) const { return *it == **this; } + bool operator!=(const iterator &it) const { return *it != **this; } + const handle &operator*() const { + if (m_ptr && !value) + value = object(PyIter_Next(m_ptr), false); + return value; + } +private: + mutable object value; +}; + +inline detail::accessor handle::operator[](handle key) const { return detail::accessor(ptr(), key.ptr(), false); } +inline detail::accessor handle::operator[](const char *key) const { return detail::accessor(ptr(), key, false); } +inline detail::accessor handle::attr(handle key) const { return detail::accessor(ptr(), key.ptr(), true); } +inline detail::accessor handle::attr(const char *key) const { return detail::accessor(ptr(), key, true); } +inline iterator handle::begin() const { return iterator(PyObject_GetIter(ptr())); } +inline iterator handle::end() const { return iterator(nullptr); } + +class str : public object { +public: + PYBIND11_OBJECT_DEFAULT(str, object, PyUnicode_Check) + str(const std::string &s) + : object(PyUnicode_FromStringAndSize(s.c_str(), s.length()), false) { + if (!m_ptr) pybind11_fail("Could not allocate string object!"); + } + + operator std::string() const { +#if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 3 + return PyUnicode_AsUTF8(m_ptr); +#else + object temp(PyUnicode_AsUTF8String(m_ptr), false); + if (temp.ptr() == nullptr) + pybind11_fail("Unable to extract string contents!"); + return PYBIND11_BYTES_AS_STRING(temp.ptr()); +#endif + } +}; + +inline pybind11::str handle::str() const { + PyObject *strValue = PyObject_Str(m_ptr); +#if PY_MAJOR_VERSION < 3 + PyObject *unicode = PyUnicode_FromEncodedObject(strValue, "utf-8", nullptr); + Py_XDECREF(strValue); strValue = unicode; +#endif + return pybind11::str(strValue, false); +} + +class bytes : public object { +public: + PYBIND11_OBJECT_DEFAULT(bytes, object, PYBIND11_BYTES_CHECK) + + bytes(const std::string &s) + : object(PYBIND11_BYTES_FROM_STRING_AND_SIZE(s.data(), s.size()), false) { + if (!m_ptr) pybind11_fail("Could not allocate bytes object!"); + } + + operator std::string() const { + char *buffer; + ssize_t length; + int err = PYBIND11_BYTES_AS_STRING_AND_SIZE(m_ptr, &buffer, &length); + if (err == -1) + pybind11_fail("Unable to extract bytes contents!"); + return std::string(buffer, length); + } +}; + +class bool_ : public object { +public: + PYBIND11_OBJECT_DEFAULT(bool_, object, PyBool_Check) + bool_(bool value) : object(value ? Py_True : Py_False, true) { } + operator bool() const { return m_ptr && PyLong_AsLong(m_ptr) != 0; } +}; + +class int_ : public object { +public: + PYBIND11_OBJECT_DEFAULT(int_, object, PYBIND11_LONG_CHECK) + template <typename T, + typename std::enable_if<std::is_integral<T>::value, int>::type = 0> + int_(T value) { + if (sizeof(T) <= sizeof(long)) { + if (std::is_signed<T>::value) + m_ptr = PyLong_FromLong((long) value); + else + m_ptr = PyLong_FromUnsignedLong((unsigned long) value); + } else { + if (std::is_signed<T>::value) + m_ptr = PyLong_FromLongLong((long long) value); + else + m_ptr = PyLong_FromUnsignedLongLong((unsigned long long) value); + } + if (!m_ptr) pybind11_fail("Could not allocate int object!"); + } + + template <typename T, + typename std::enable_if<std::is_integral<T>::value, int>::type = 0> + operator T() const { + if (sizeof(T) <= sizeof(long)) { + if (std::is_signed<T>::value) + return (T) PyLong_AsLong(m_ptr); + else + return (T) PyLong_AsUnsignedLong(m_ptr); + } else { + if (std::is_signed<T>::value) + return (T) PYBIND11_LONG_AS_LONGLONG(m_ptr); + else + return (T) PYBIND11_LONG_AS_UNSIGNED_LONGLONG(m_ptr); + } + } +}; + +class float_ : public object { +public: + PYBIND11_OBJECT_DEFAULT(float_, object, PyFloat_Check) + float_(float value) : object(PyFloat_FromDouble((double) value), false) { + if (!m_ptr) pybind11_fail("Could not allocate float object!"); + } + float_(double value) : object(PyFloat_FromDouble((double) value), false) { + if (!m_ptr) pybind11_fail("Could not allocate float object!"); + } + operator float() const { return (float) PyFloat_AsDouble(m_ptr); } + operator double() const { return (double) PyFloat_AsDouble(m_ptr); } +}; + +class weakref : public object { +public: + PYBIND11_OBJECT_DEFAULT(weakref, object, PyWeakref_Check) + weakref(handle obj, handle callback = handle()) : object(PyWeakref_NewRef(obj.ptr(), callback.ptr()), false) { + if (!m_ptr) pybind11_fail("Could not allocate weak reference!"); + } +}; + +class slice : public object { +public: + PYBIND11_OBJECT_DEFAULT(slice, object, PySlice_Check) + slice(ssize_t start_, ssize_t stop_, ssize_t step_) { + int_ start(start_), stop(stop_), step(step_); + m_ptr = PySlice_New(start.ptr(), stop.ptr(), step.ptr()); + if (!m_ptr) pybind11_fail("Could not allocate slice object!"); + } + bool compute(ssize_t length, ssize_t *start, ssize_t *stop, ssize_t *step, ssize_t *slicelength) const { + return PySlice_GetIndicesEx((PYBIND11_SLICE_OBJECT *) m_ptr, length, + start, stop, step, slicelength) == 0; + } +}; + +class capsule : public object { +public: + PYBIND11_OBJECT_DEFAULT(capsule, object, PyCapsule_CheckExact) + capsule(PyObject *obj, bool borrowed) : object(obj, borrowed) { } + capsule(void *value, void (*destruct)(PyObject *) = nullptr) + : object(PyCapsule_New(value, nullptr, destruct), false) { + if (!m_ptr) pybind11_fail("Could not allocate capsule object!"); + } + template <typename T> operator T *() const { + T * result = static_cast<T *>(PyCapsule_GetPointer(m_ptr, nullptr)); + if (!result) pybind11_fail("Unable to extract capsule contents!"); + return result; + } +}; + +class tuple : public object { +public: + PYBIND11_OBJECT(tuple, object, PyTuple_Check) + tuple(size_t size = 0) : object(PyTuple_New((ssize_t) size), false) { + if (!m_ptr) pybind11_fail("Could not allocate tuple object!"); + } + size_t size() const { return (size_t) PyTuple_Size(m_ptr); } + detail::tuple_accessor operator[](size_t index) const { return detail::tuple_accessor(ptr(), index); } +}; + +class dict : public object { +public: + PYBIND11_OBJECT(dict, object, PyDict_Check) + dict() : object(PyDict_New(), false) { + if (!m_ptr) pybind11_fail("Could not allocate dict object!"); + } + size_t size() const { return (size_t) PyDict_Size(m_ptr); } + detail::dict_iterator begin() const { return (++detail::dict_iterator(ptr(), 0)); } + detail::dict_iterator end() const { return detail::dict_iterator(); } + void clear() const { PyDict_Clear(ptr()); } +}; + +class list : public object { +public: + PYBIND11_OBJECT(list, object, PyList_Check) + list(size_t size = 0) : object(PyList_New((ssize_t) size), false) { + if (!m_ptr) pybind11_fail("Could not allocate list object!"); + } + size_t size() const { return (size_t) PyList_Size(m_ptr); } + detail::list_accessor operator[](size_t index) const { return detail::list_accessor(*this, index); } + void append(const object &object) const { PyList_Append(m_ptr, object.ptr()); } +}; + +class set : public object { +public: + PYBIND11_OBJECT(set, object, PySet_Check) + set() : object(PySet_New(nullptr), false) { + if (!m_ptr) pybind11_fail("Could not allocate set object!"); + } + size_t size() const { return (size_t) PySet_Size(m_ptr); } + bool add(const object &object) const { return PySet_Add(m_ptr, object.ptr()) == 0; } + void clear() const { PySet_Clear(m_ptr); } +}; + +class function : public object { +public: + PYBIND11_OBJECT_DEFAULT(function, object, PyCallable_Check) + bool is_cpp_function() const { + handle fun = detail::get_function(m_ptr); + return fun && PyCFunction_Check(fun.ptr()); + } +}; + +class buffer : public object { +public: + PYBIND11_OBJECT_DEFAULT(buffer, object, PyObject_CheckBuffer) + + buffer_info request(bool writable = false) { + int flags = PyBUF_STRIDES | PyBUF_FORMAT; + if (writable) flags |= PyBUF_WRITABLE; + Py_buffer *view = new Py_buffer(); + if (PyObject_GetBuffer(m_ptr, view, flags) != 0) + throw error_already_set(); + return buffer_info(view); + } +}; + +inline size_t len(handle h) { + ssize_t result = PyObject_Length(h.ptr()); + if (result < 0) + pybind11_fail("Unable to compute length of object"); + return (size_t) result; +} + +NAMESPACE_END(pybind11) diff --git a/stormpy/resources/pybind11/include/pybind11/stl.h b/stormpy/resources/pybind11/include/pybind11/stl.h new file mode 100644 index 000000000..97ccdbc84 --- /dev/null +++ b/stormpy/resources/pybind11/include/pybind11/stl.h @@ -0,0 +1,197 @@ +/* + pybind11/complex.h: Complex number support + + Copyright (c) 2015 Wenzel Jakob <wenzel@inf.ethz.ch> + + All rights reserved. Use of this source code is governed by a + BSD-style license that can be found in the LICENSE file. +*/ + +#pragma once + +#include "pybind11.h" +#include <set> +#include <unordered_set> +#include <map> +#include <unordered_map> +#include <iostream> +#include <list> + +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable: 4127) // warning C4127: Conditional expression is constant +#endif + +NAMESPACE_BEGIN(pybind11) +NAMESPACE_BEGIN(detail) + +template <typename Type, typename Key> struct set_caster { + typedef Type type; + typedef type_caster<typename intrinsic_type<Key>::type> key_conv; + + bool load(handle src, bool convert) { + pybind11::set s(src, true); + if (!s.check()) + return false; + value.clear(); + key_conv conv; + for (auto entry : s) { + if (!conv.load(entry, convert)) + return false; + value.insert((Key) conv); + } + return true; + } + + static handle cast(const type &src, return_value_policy policy, handle parent) { + pybind11::set s; + for (auto const &value: src) { + object value_ = object(key_conv::cast(value, policy, parent), false); + if (!value_ || !s.add(value_)) + return handle(); + } + return s.release(); + } + + PYBIND11_TYPE_CASTER(type, _("set<") + key_conv::name() + _(">")); +}; + +template <typename Type, typename Key, typename Value> struct map_caster { + typedef Type type; + typedef type_caster<typename intrinsic_type<Key>::type> key_conv; + typedef type_caster<typename intrinsic_type<Value>::type> value_conv; + + bool load(handle src, bool convert) { + dict d(src, true); + if (!d.check()) + return false; + key_conv kconv; + value_conv vconv; + value.clear(); + for (auto it : d) { + if (!kconv.load(it.first.ptr(), convert) || + !vconv.load(it.second.ptr(), convert)) + return false; + value.emplace((Key) kconv, (Value) vconv); + } + return true; + } + + static handle cast(const type &src, return_value_policy policy, handle parent) { + dict d; + for (auto const &kv: src) { + object key = object(key_conv::cast(kv.first, policy, parent), false); + object value = object(value_conv::cast(kv.second, policy, parent), false); + if (!key || !value) + return handle(); + d[key] = value; + } + return d.release(); + } + + PYBIND11_TYPE_CASTER(type, _("dict<") + key_conv::name() + _(", ") + value_conv::name() + _(">")); +}; + +template <typename Type, typename Value> struct list_caster { + typedef Type type; + typedef type_caster<typename intrinsic_type<Value>::type> value_conv; + + bool load(handle src, bool convert) { + list l(src, true); + if (!l.check()) + return false; + value_conv conv; + value.clear(); + reserve_maybe(l, &value); + for (auto it : l) { + if (!conv.load(it, convert)) + return false; + value.push_back((Value) conv); + } + return true; + } + + template <typename T = Type, + typename std::enable_if<std::is_same<decltype(std::declval<T>().reserve(0)), void>::value, int>::type = 0> + void reserve_maybe(list l, Type *) { value.reserve(l.size()); } + void reserve_maybe(list, void *) { } + + static handle cast(const Type &src, return_value_policy policy, handle parent) { + list l(src.size()); + size_t index = 0; + for (auto const &value: src) { + object value_ = object(value_conv::cast(value, policy, parent), false); + if (!value_) + return handle(); + PyList_SET_ITEM(l.ptr(), index++, value_.release().ptr()); // steals a reference + } + return l.release(); + } + + PYBIND11_TYPE_CASTER(Type, _("list<") + value_conv::name() + _(">")); +}; + +template <typename Type, typename Alloc> struct type_caster<std::vector<Type, Alloc>> + : list_caster<std::vector<Type, Alloc>, Type> { }; + +template <typename Type, typename Alloc> struct type_caster<std::list<Type, Alloc>> + : list_caster<std::list<Type, Alloc>, Type> { }; + +template <typename Type, size_t Size> struct type_caster<std::array<Type, Size>> { + typedef std::array<Type, Size> array_type; + typedef type_caster<typename intrinsic_type<Type>::type> value_conv; + + bool load(handle src, bool convert) { + list l(src, true); + if (!l.check()) + return false; + if (l.size() != Size) + return false; + value_conv conv; + size_t ctr = 0; + for (auto it : l) { + if (!conv.load(it, convert)) + return false; + value[ctr++] = (Type) conv; + } + return true; + } + + static handle cast(const array_type &src, return_value_policy policy, handle parent) { + list l(Size); + size_t index = 0; + for (auto const &value: src) { + object value_ = object(value_conv::cast(value, policy, parent), false); + if (!value_) + return handle(); + PyList_SET_ITEM(l.ptr(), index++, value_.release().ptr()); // steals a reference + } + return l.release(); + } + PYBIND11_TYPE_CASTER(array_type, _("list<") + value_conv::name() + _(">") + _("[") + _<Size>() + _("]")); +}; + +template <typename Key, typename Compare, typename Alloc> struct type_caster<std::set<Key, Compare, Alloc>> + : set_caster<std::set<Key, Compare, Alloc>, Key> { }; + +template <typename Key, typename Hash, typename Equal, typename Alloc> struct type_caster<std::unordered_set<Key, Hash, Equal, Alloc>> + : set_caster<std::unordered_set<Key, Hash, Equal, Alloc>, Key> { }; + +template <typename Key, typename Value, typename Compare, typename Alloc> struct type_caster<std::map<Key, Value, Compare, Alloc>> + : map_caster<std::map<Key, Value, Compare, Alloc>, Key, Value> { }; + +template <typename Key, typename Value, typename Hash, typename Equal, typename Alloc> struct type_caster<std::unordered_map<Key, Value, Hash, Equal, Alloc>> + : map_caster<std::unordered_map<Key, Value, Hash, Equal, Alloc>, Key, Value> { }; + +NAMESPACE_END(detail) + +inline std::ostream &operator<<(std::ostream &os, const handle &obj) { + os << (std::string) obj.str(); + return os; +} + +NAMESPACE_END(pybind11) + +#if defined(_MSC_VER) +#pragma warning(pop) +#endif diff --git a/stormpy/resources/pybind11/include/pybind11/typeid.h b/stormpy/resources/pybind11/include/pybind11/typeid.h new file mode 100644 index 000000000..b395110f6 --- /dev/null +++ b/stormpy/resources/pybind11/include/pybind11/typeid.h @@ -0,0 +1,53 @@ +/* + pybind11/typeid.h: Compiler-independent access to type identifiers + + Copyright (c) 2015 Wenzel Jakob <wenzel@inf.ethz.ch> + + All rights reserved. Use of this source code is governed by a + BSD-style license that can be found in the LICENSE file. +*/ + +#pragma once + +#include <cstdio> +#include <cstdlib> + +#if defined(__GNUG__) +#include <cxxabi.h> +#endif + +NAMESPACE_BEGIN(pybind11) +NAMESPACE_BEGIN(detail) +/// Erase all occurrences of a substring +inline void erase_all(std::string &string, const std::string &search) { + for (size_t pos = 0;;) { + pos = string.find(search, pos); + if (pos == std::string::npos) break; + string.erase(pos, search.length()); + } +} + +PYBIND11_NOINLINE inline void clean_type_id(std::string &name) { +#if defined(__GNUG__) + int status = 0; + std::unique_ptr<char, void (*)(void *)> res { + abi::__cxa_demangle(name.c_str(), nullptr, nullptr, &status), std::free }; + if (status == 0) + name = res.get(); +#else + detail::erase_all(name, "class "); + detail::erase_all(name, "struct "); + detail::erase_all(name, "enum "); +#endif + detail::erase_all(name, "pybind11::"); +} +NAMESPACE_END(detail) + +/// Return a string representation of a C++ type +template <typename T> static std::string type_id() { + std::string name(typeid(T).name()); + detail::clean_type_id(name); + return name; +} + +NAMESPACE_END(pybind11) diff --git a/stormpy/resources/pybind11/pybind11/__init__.py b/stormpy/resources/pybind11/pybind11/__init__.py new file mode 100644 index 000000000..af8f14a8e --- /dev/null +++ b/stormpy/resources/pybind11/pybind11/__init__.py @@ -0,0 +1,11 @@ +from ._version import version_info, __version__ + + +def get_include(): + import os + try: + from pip import locations + return os.path.dirname( + locations.distutils_scheme('pybind11')['headers']) + except ImportError: + return 'include' diff --git a/stormpy/resources/pybind11/pybind11/_version.py b/stormpy/resources/pybind11/pybind11/_version.py new file mode 100644 index 000000000..93cf8a709 --- /dev/null +++ b/stormpy/resources/pybind11/pybind11/_version.py @@ -0,0 +1,2 @@ +version_info = (1, 5, 'dev0') +__version__ = '.'.join(map(str, version_info)) diff --git a/stormpy/resources/pybind11/setup.cfg b/stormpy/resources/pybind11/setup.cfg new file mode 100644 index 000000000..3c6e79cf3 --- /dev/null +++ b/stormpy/resources/pybind11/setup.cfg @@ -0,0 +1,2 @@ +[bdist_wheel] +universal=1 diff --git a/stormpy/resources/pybind11/setup.py b/stormpy/resources/pybind11/setup.py new file mode 100644 index 000000000..362b753b0 --- /dev/null +++ b/stormpy/resources/pybind11/setup.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python + +# Setup script for PyPI; use CMakeFile.txt to build the example application + +from setuptools import setup +from pybind11 import __version__ + +setup( + name='pybind11', + version=__version__, + description='Seamless operability between C++11 and Python', + author='Wenzel Jakob', + author_email='wenzel@inf.ethz.ch', + url='https://github.com/wjakob/pybind11', + download_url='https://github.com/wjakob/pybind11/tarball/v' + __version__, + packages=['pybind11'], + license='BSD', + headers=[ + 'include/pybind11/attr.h', + 'include/pybind11/cast.h', + 'include/pybind11/complex.h', + 'include/pybind11/descr.h', + 'include/pybind11/numpy.h', + 'include/pybind11/pybind11.h', + 'include/pybind11/stl.h', + 'include/pybind11/common.h', + 'include/pybind11/functional.h', + 'include/pybind11/operators.h', + 'include/pybind11/pytypes.h', + 'include/pybind11/typeid.h' + ], + classifiers=[ + 'Development Status :: 5 - Production/Stable', + 'Intended Audience :: Developers', + 'Topic :: Software Development :: Libraries :: Python Modules', + 'Topic :: Utilities', + 'Programming Language :: C++', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.2', + 'Programming Language :: Python :: 3.3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'License :: OSI Approved :: BSD License', + ], + keywords='C++11, Python bindings', + long_description="""pybind11 is a lightweight header library that exposes +C++ types in Python and vice versa, mainly to create Python bindings of +existing C++ code. Its goals and syntax are similar to the excellent +Boost.Python library by David Abrahams: to minimize boilerplate code in +traditional extension modules by inferring type information using compile-time +introspection. + +The main issue with Boost.Python-and the reason for creating such a similar +project-is Boost. Boost is an enormously large and complex suite of utility +libraries that works with almost every C++ compiler in existence. This +compatibility has its cost: arcane template tricks and workarounds are +necessary to support the oldest and buggiest of compiler specimens. Now that +C++11-compatible compilers are widely available, this heavy machinery has +become an excessively large and unnecessary dependency. + +Think of this library as a tiny self-contained version of Boost.Python with +everything stripped away that isn't relevant for binding generation. Without +comments, the core header files only require ~2.5K lines of code and depend on +Python (2.7 or 3.x) and the C++ standard library. This compact implementation +was possible thanks to some of the new C++11 language features (specifically: +tuples, lambda functions and variadic templates). Since its creation, this +library has grown beyond Boost.Python in many ways, leading to dramatically +simpler binding code in many common situations.""") diff --git a/stormpy/resources/pybind11/tools/mkdoc.py b/stormpy/resources/pybind11/tools/mkdoc.py new file mode 100644 index 000000000..09c09cfb0 --- /dev/null +++ b/stormpy/resources/pybind11/tools/mkdoc.py @@ -0,0 +1,241 @@ +#!/usr/bin/env python3 +# +# Syntax: mkdoc.py [-I<path> ..] [.. a list of header files ..] +# +# Extract documentation from C++ header files to use it in Python bindings +# + +import os, sys, platform, re, textwrap +from clang import cindex +from clang.cindex import CursorKind +from collections import OrderedDict +from threading import Thread, Semaphore +from multiprocessing import cpu_count + +if platform.system() == 'Darwin': + libclang = '/opt/llvm/lib/libclang.dylib' + if os.path.exists(libclang): + cindex.Config.set_library_path(os.path.dirname(libclang)) + +RECURSE_LIST = [ + CursorKind.TRANSLATION_UNIT, + CursorKind.NAMESPACE, + CursorKind.CLASS_DECL, + CursorKind.STRUCT_DECL, + CursorKind.CLASS_TEMPLATE +] + +PRINT_LIST = [ + CursorKind.CLASS_DECL, + CursorKind.STRUCT_DECL, + CursorKind.CLASS_TEMPLATE, + CursorKind.FUNCTION_DECL, + CursorKind.FUNCTION_TEMPLATE, + CursorKind.CXX_METHOD, + CursorKind.CONSTRUCTOR, + CursorKind.FIELD_DECL +] + +CPP_OPERATORS = { + '<=' : 'le', '>=' : 'ge', '==' : 'eq', '!=' : 'ne', '[]' : 'array', + '+=' : 'iadd', '-=' : 'isub', '*=' : 'imul', '/=' : 'idiv', '%=' : + 'imod', '&=' : 'iand', '|=' : 'ior', '^=' : 'ixor', '<<=' : 'ilshift', + '>>=' : 'irshift', '++' : 'inc', '--' : 'dec', '<<' : 'lshift', '>>' : + 'rshift', '&&' : 'land', '||' : 'lor', '!' : 'lnot', '~' : 'bnot', '&' + : 'band', '|' : 'bor', '+' : 'add', '-' : 'sub', '*' : 'mul', '/' : + 'div', '%' : 'mod', '<' : 'lt', '>' : 'gt', '=' : 'assign' +} +CPP_OPERATORS = OrderedDict(sorted(CPP_OPERATORS.items(), key=lambda t: -len(t[0]))) + +job_count = cpu_count() +job_semaphore = Semaphore(job_count) + +registered_names = dict() + +def d(s): + return s.decode('utf8') + +def sanitize_name(name): + global registered_names + for k, v in CPP_OPERATORS.items(): + name = name.replace('operator%s' % k, 'operator_%s' % v) + name = name.replace('<', '_') + name = name.replace('>', '_') + name = name.replace(' ', '_') + name = name.replace(',', '_') + if name in registered_names: + registered_names[name] += 1 + name += '_' + str(registered_names[name]) + else: + registered_names[name] = 1 + return '__doc_' + name + +def process_comment(comment): + result = '' + + # Remove C++ comment syntax + for s in comment.splitlines(): + s = s.strip() + if s.startswith('/*'): + s = s[2:].lstrip('* \t') + elif s.endswith('*/'): + s = s[:-2].rstrip('* \t') + elif s.startswith('///'): + s = s[3:] + if s.startswith('*'): + s = s[1:] + result += s.strip() + '\n' + + # Doxygen tags + cpp_group = '([\w:]+)' + param_group = '([\[\w:\]]+)' + + s = result + s = re.sub(r'\\c\s+%s' % cpp_group, r'``\1``', s) + s = re.sub(r'\\a\s+%s' % cpp_group, r'*\1*', s) + s = re.sub(r'\\e\s+%s' % cpp_group, r'*\1*', s) + s = re.sub(r'\\em\s+%s' % cpp_group, r'*\1*', s) + s = re.sub(r'\\b\s+%s' % cpp_group, r'**\1**', s) + s = re.sub(r'\\param%s?\s+%s' % (param_group, cpp_group), r'\n\n$Parameter ``\2``:\n\n', s) + + for in_, out_ in { + 'return' : 'Returns', + 'author' : 'Author', + 'authors' : 'Authors', + 'copyright' : 'Copyright', + 'date' : 'Date', + 'remark' : 'Remark', + 'sa' : 'See also', + 'see' : 'See also', + 'extends' : 'Extends', + 'throw' : 'Throws', + 'throws' : 'Throws' }.items(): + s = re.sub(r'\\%s\s*' % in_, r'\n\n$%s:\n\n' % out_, s) + + s = re.sub(r'\\details\s*', r'\n\n', s) + s = re.sub(r'\\brief\s*', r'', s) + s = re.sub(r'\\short\s*', r'', s) + s = re.sub(r'\\ref\s*', r'', s) + + # HTML/TeX tags + s = re.sub(r'<tt>([^<]*)</tt>', r'``\1``', s) + s = re.sub(r'<em>([^<]*)</em>', r'*\1*', s) + s = re.sub(r'<b>([^<]*)</b>', r'**\1**', s) + s = re.sub(r'\\f\$([^\$]*)\\f\$', r'$\1$', s) + + s = s.replace('``true``', '``True``') + s = s.replace('``false``', '``False``') + + # Re-flow text + wrapper = textwrap.TextWrapper() + wrapper.expand_tabs = True + wrapper.replace_whitespace = True + wrapper.width = 75 + wrapper.initial_indent = wrapper.subsequent_indent = '' + + result = '' + for x in re.split(r'\n{2,}', s): + wrapped = wrapper.fill(x.strip()) + if len(wrapped) > 0 and wrapped[0] == '$': + result += wrapped[1:] + '\n' + wrapper.initial_indent = wrapper.subsequent_indent = ' '*4 + else: + result += wrapped + '\n\n' + wrapper.initial_indent = wrapper.subsequent_indent = '' + return result.rstrip() + + +def extract(filename, node, prefix, output): + num_extracted = 0 + if not (node.location.file is None or os.path.samefile(d(node.location.file.name), filename)): + return 0 + if node.kind in RECURSE_LIST: + sub_prefix = prefix + if node.kind != CursorKind.TRANSLATION_UNIT: + if len(sub_prefix) > 0: + sub_prefix += '_' + sub_prefix += d(node.spelling) + for i in node.get_children(): + num_extracted += extract(filename, i, sub_prefix, output) + if num_extracted == 0: + return 0 + if node.kind in PRINT_LIST: + comment = d(node.raw_comment) if node.raw_comment is not None else '' + comment = process_comment(comment) + name = sanitize_name(prefix + '_' + d(node.spelling)) + output.append('\nstatic const char *%s = %sR"doc(%s)doc";' % (name, '\n' if '\n' in comment else '', comment)) + num_extracted += 1 + return num_extracted + +class ExtractionThread(Thread): + def __init__ (self, filename, parameters, output): + Thread.__init__(self) + self.filename = filename + self.parameters = parameters + self.output = output + job_semaphore.acquire() + + def run(self): + print('Processing "%s" ..' % self.filename, file = sys.stderr) + try: + index = cindex.Index(cindex.conf.lib.clang_createIndex(False, True)) + tu = index.parse(self.filename, self.parameters) + extract(self.filename, tu.cursor, '', self.output) + finally: + job_semaphore.release() + +if __name__ == '__main__': + parameters = ['-x', 'c++', '-std=c++11'] + filenames = [] + + for item in sys.argv[1:]: + if item.startswith('-'): + parameters.append(item) + else: + filenames.append(item) + + if len(filenames) == 0: + print('Syntax: %s [.. a list of header files ..]' % sys.argv[0]) + exit(-1) + + print('''/* + This file contains docstrings for the Python bindings. + Do not edit! These were automatically extracted by mkdoc.py + */ + +#define __EXPAND(x) x +#define __COUNT(_1, _2, _3, _4, _5, COUNT, ...) COUNT +#define __VA_SIZE(...) __EXPAND(__COUNT(__VA_ARGS__, 5, 4, 3, 2, 1)) +#define __CAT1(a, b) a ## b +#define __CAT2(a, b) __CAT1(a, b) +#define __DOC1(n1) __doc_##n1 +#define __DOC2(n1, n2) __doc_##n1##_##n2 +#define __DOC3(n1, n2, n3) __doc_##n1##_##n2##_##n3 +#define __DOC4(n1, n2, n3, n4) __doc_##n1##_##n2##_##n3##_##n4 +#define __DOC5(n1, n2, n3, n4, n5) __doc_##n1##_##n2##_##n3##_##n4_##n5 +#define DOC(...) __EXPAND(__EXPAND(__CAT2(__DOC, __VA_SIZE(__VA_ARGS__)))(__VA_ARGS__)) + +#if defined(__GNUG__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-variable" +#endif +''') + + output = [] + for filename in filenames: + thr = ExtractionThread(filename, parameters, output) + thr.start() + + print('Waiting for jobs to finish ..', file = sys.stderr) + for i in range(job_count): + job_semaphore.acquire() + + output.sort() + for l in output: + print(l) + + print(''' +#if defined(__GNUG__) +#pragma GCC diagnostic pop +#endif +''') diff --git a/stormpy/setup.cfg b/stormpy/setup.cfg new file mode 100644 index 000000000..93d2dc675 --- /dev/null +++ b/stormpy/setup.cfg @@ -0,0 +1,2 @@ +[build_ext] +use-cln=0 diff --git a/stormpy/setup.py b/stormpy/setup.py new file mode 100755 index 000000000..38a96829b --- /dev/null +++ b/stormpy/setup.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python +from setuptools import setup +from distutils.core import Extension +from distutils.command.build_ext import build_ext +import os.path +import platform +from glob import glob + +PROJECT_DIR = os.path.abspath(os.path.dirname(os.path.realpath(__file__))) + +# Glob source files for modules +core_sources = glob(os.path.join('src', 'core', '*.cpp')) +info_sources = glob(os.path.join('src', 'info', '*.cpp')) + +# Configuration shared between external modules follows + +# To help along, if storm and/or pybind is not system installed, retrieve from storm distribution +include_dirs = ['.', 'src', 'resources/pybind11/include'] +local_storm_path = os.path.join(PROJECT_DIR, '..') +if os.path.exists(local_storm_path): + include_dirs.append(local_storm_path) + +# Like includes, also add local path for library, assuming made in 'build' +library_dirs = [] +local_storm_lib_path = os.path.join(PROJECT_DIR, '..', 'build/src') +if os.path.exists(local_storm_lib_path): + library_dirs.append(local_storm_lib_path) + +libraries = ['storm'] +extra_compile_args = ['-std=c++11'] +define_macros = [] + +extra_link_args = [] +if platform.system() == 'Darwin': + extra_link_args.append('-Wl,-rpath,'+library_dirs[0]) + +ext_core = Extension( + name='core', + sources=['src/mod_core.cpp'] + core_sources, + include_dirs=include_dirs, + libraries=libraries, + library_dirs=library_dirs, + extra_compile_args=extra_compile_args, + define_macros=define_macros, + extra_link_args=extra_link_args +) + +ext_info = Extension( + name='info.info', + sources=['src/mod_info.cpp'] + info_sources, + include_dirs=include_dirs, + libraries=libraries, + library_dirs=library_dirs, + extra_compile_args=extra_compile_args, + define_macros=define_macros, + extra_link_args=extra_link_args +) + +class stormpy_build_ext(build_ext): + """Extend build_ext to provide CLN toggle option + """ + user_options = build_ext.user_options + [ + ('use-cln', None, + "use cln numbers instead of gmpxx") + ] + + def __init__(self, *args, **kwargs): + build_ext.__init__(self, *args, **kwargs) + + def initialize_options (self): + build_ext.initialize_options(self) + self.use_cln = None + + def finalize_options(self): + build_ext.finalize_options(self) + + if self.use_cln: + self.libraries += ['cln'] + if not self.define: + self.define = [] + else: + self.define = list(self.define) + self.define += [('STORMPY_USE_CLN', 1)] + else: + self.libraries += ['gmp', 'gmpxx'] + if not self.undef: + self.undef = [] + self.undef += ['STORMPY_USE_CLN'] + + if library_dirs: + # Makes local storm library lookup that much easier + self.rpath += library_dirs + +setup(name="stormpy", + version="0.9", + author="M. Volk", + author_email="matthias.volk@cs.rwth-aachen.de", + maintainer="S. Junges", + maintainer_email="sebastian.junges@cs.rwth-aachen.de", + url="http://moves.rwth-aachen.de", + description="stormpy - Python Bindings for Storm", + packages=['stormpy', 'stormpy.info'], + package_dir={'':'lib'}, + ext_package='stormpy', + ext_modules=[ext_core, ext_info + ], + cmdclass={ + 'build_ext': stormpy_build_ext, + } +) diff --git a/stormpy/src/CMakeLists.txt b/stormpy/src/CMakeLists.txt new file mode 100644 index 000000000..3574ad93c --- /dev/null +++ b/stormpy/src/CMakeLists.txt @@ -0,0 +1,42 @@ +# This is a CMake example for Python + +INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src ${stormpy_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS}) +INCLUDE_DIRECTORIES(${pybind11_incdir}) + +FILE(GLOB core_files "core/*.cpp") +FILE(GLOB info_files "info/*.cpp") +ADD_LIBRARY(stormpy_core SHARED mod_core.cpp ${core_files}) +ADD_LIBRARY(stormpy_info SHARED mod_info.cpp ${info_files}) + +SET(STORMPY_SOURCE_DIR "${PROJECT_SOURCE_DIR}") +SET(STORMPY_OUTPUT_DIR "${PROJECT_BINARY_DIR}/stormpy") + +SET_TARGET_PROPERTIES(stormpy_core PROPERTIES + OUTPUT_NAME core + PREFIX "" + SUFFIX ".so" + LIBRARY_OUTPUT_DIRECTORY ${STORMPY_OUTPUT_DIR}/ +) + +SET_TARGET_PROPERTIES(stormpy_info PROPERTIES + OUTPUT_NAME info + PREFIX "" + SUFFIX ".so" + LIBRARY_OUTPUT_DIRECTORY ${STORMPY_OUTPUT_DIR}/info +) + +add_custom_target(stormpy_files) +add_custom_command(TARGET stormpy_files POST_BUILD COMMAND ${CMAKE_COMMAND} -E + copy_directory ${CMAKE_SOURCE_DIR}/stormpy ${STORMPY_OUTPUT_DIR} + ) + +if(BUILD_STATIC) + TARGET_LINK_LIBRARIES(stormpy_core lib_storm_static ${stormpy_LIBRARIES_STATIC} ${PYTHON_LIBRARIES} ${libs_static} ) + TARGET_LINK_LIBRARIES(stormpy_info lib_storm_static ${stormpy_LIBRARIES_STATIC} ${PYTHON_LIBRARIES} ${libs_static} ) +else() + TARGET_LINK_LIBRARIES(stormpy_core lib_storm ${stormpy_LIBRARIES_DYNAMIC} ${PYTHON_LIBRARIES} ${libs_dynamic}) + TARGET_LINK_LIBRARIES(stormpy_info lib_storm ${stormpy_LIBRARIES_DYNAMIC} ${PYTHON_LIBRARIES} ${libs_dynamic}) +endif() +# +add_custom_target(stormpy DEPENDS stormpy_files stormpy_core stormpy_info) + diff --git a/stormpy/src/common.h b/stormpy/src/common.h new file mode 100644 index 000000000..bff6e3be3 --- /dev/null +++ b/stormpy/src/common.h @@ -0,0 +1,124 @@ +/* + * common.h + * + * Created on: 15 Apr 2016 + * Author: hbruintjes + */ + +#pragma once + +#include <pybind11/pybind11.h> +#include <pybind11/operators.h> +#include <pybind11/stl.h> +#include <tuple> + +namespace py = pybind11; + +#if PY_MAJOR_VERSION >= 3 +#define PY_DIV "__truediv__" +#define PY_RDIV "__rtruediv__" +#else +#define PY_DIV "__div__" +#define PY_RDIV "__rdiv__" +#endif + +namespace pybind11 { +namespace detail { +/** + * Dummy type caster for handle, so functions can return pybind11 handles directly + */ +template <> class type_caster<handle> { +public: + bool load(handle src, bool) { + value = handle(src).inc_ref(); + return true; + } + + static handle cast(handle src, return_value_policy policy, handle parent) { + switch(policy) { + case return_value_policy::automatic: + case return_value_policy::copy: + case return_value_policy::take_ownership: + return handle(src); + case return_value_policy::reference: + return handle(src).inc_ref(); + case return_value_policy::reference_internal: + parent.inc_ref(); + return handle(src); + } + return handle(src); + } + PYBIND11_TYPE_CASTER(handle, _("handle")); +}; +/* +template <typename TupleType, typename ... Keys> struct tuple_caster { + typedef TupleType type; + template<typename Type> + using type_conv = type_caster<typename intrinsic_type<Type>::type>; + + bool load(handle src, bool convert) { + pybind11::tuple tup(src, true); + if (!tup.check()) + return false; + + return loadItem<0, Keys...>(tup, convert); + } + + static handle cast(const type &src, return_value_policy policy, handle parent) { + pybind11::tuple tup(sizeof...(Keys)); + if (!castItem<0, Keys...>(tup, src, policy, parent)) { + return handle(); + } + + return tup.release(); + } + +private: + template<int N, typename Type, typename ... Types> + bool loadItem(pybind11::tuple& tup, bool convert) { + type_conv<Type> conv; + if (!conv.load(tup[N], convert)) + return false; + std::get<N>(value) = static_cast<Type>(conv); + return loadItem<N+1, Types...>(tup, convert); + } + + template<int N, typename Type> + bool loadItem(pybind11::tuple& tup, bool convert) { + type_conv<Type> conv; + if (!conv.load(tup[N], convert)) + return false; + std::get<N>(value) = static_cast<Type>(conv); + return true; + } + + template<int N, typename Type, typename ... Types> + static bool castItem(pybind11::tuple& tup, const type &src, return_value_policy policy, handle parent) { + auto obj = type_conv<Type>::cast(std::get<N>(src), policy, parent); + object value_ = object(obj, false); + if (!obj) { + return false; + } + return castItem<N+1, Types...>(tup, src, policy, parent); + } + + template<int N, typename Type> + static bool castItem(pybind11::tuple& tu, const type &src, return_value_policy policy, handle parent) { + auto obj = type_conv<Type>::cast(std::get<N>(src), policy, parent); + object value_ = object(obj, false); + if (!obj) { + return false; + } + return true; + } +}; + +template <typename ... Types> struct type_caster<std::tuple<Types...>> + : tuple_caster<std::tuple<Types...>, Types...> { }; + +template <typename Type1, typename Type2> struct type_caster<std::pair<Type1, Type2>> + : tuple_caster<std::pair<Type1, Type2>, Type1, Type2> { }; +*/ + +} +} diff --git a/stormpy/src/core/common.h b/stormpy/src/core/common.h new file mode 100644 index 000000000..8ef7c3fa7 --- /dev/null +++ b/stormpy/src/core/common.h @@ -0,0 +1,4 @@ +#include "types.h" + +//toString +#include "src/helpers.h" diff --git a/stormpy/src/core/core.cpp b/stormpy/src/core/core.cpp new file mode 100644 index 000000000..8728f81d4 --- /dev/null +++ b/stormpy/src/core/core.cpp @@ -0,0 +1,16 @@ +#include "core.h" + +#include "common.h" + +//#include <src/utility/storm.h> + +// Thin wrapper for initializing +void setupStormLib(std::string const& args) { +// storm::utility::setUp(); +// storm::settings::SettingsManager::manager().setFromString(args); +} + +void define_core(py::module& m) { + + m.def("set_up", &setupStormLib); +} diff --git a/stormpy/src/core/core.h b/stormpy/src/core/core.h new file mode 100644 index 000000000..0f53b21bd --- /dev/null +++ b/stormpy/src/core/core.h @@ -0,0 +1,8 @@ +#ifndef PYTHON_CORE_CORE_H_ +#define PYTHON_CORE_CORE_H_ + +#include "src/common.h" + +void define_core(py::module& m); + +#endif /* PYTHON_CORE_CORE_H_ */ diff --git a/stormpy/src/core/types.h b/stormpy/src/core/types.h new file mode 100644 index 000000000..e852c6761 --- /dev/null +++ b/stormpy/src/core/types.h @@ -0,0 +1,26 @@ +#ifndef PYTHON_CORE_TYPES_H_ +#define PYTHON_CORE_TYPES_H_ + +/*#include <carl/numbers/numbers.h> +#include <carl/core/Variable.h> +#include <carl/core/Monomial.h> +#include <carl/core/Term.h> +#include <carl/core/MultivariatePolynomial.h> +#include <carl/core/FactorizedPolynomial.h> +#include <carl/core/RationalFunction.h> + +#ifdef PYCARL_USE_CLN +typedef cln::cl_RA Rational; +#else +//typedef double Rational; +typedef mpq_class Rational; +#endif +typedef carl::Monomial::Arg Monomial; +typedef carl::Term<Rational> Term; +typedef carl::MultivariatePolynomial<Rational> Polynomial; +typedef carl::FactorizedPolynomial<Polynomial> FactorizedPolynomial; +typedef carl::RationalFunction<Polynomial> RationalFunction; +typedef carl::RationalFunction<FactorizedPolynomial> FactorizedRationalFunction; +typedef carl::PolynomialFactorizationPair<Polynomial> FactorizationPair; +*/ +#endif /* PYTHON_CORE_TYPES_H_ */ diff --git a/stormpy/src/helpers.h b/stormpy/src/helpers.h new file mode 100644 index 000000000..ffda72c19 --- /dev/null +++ b/stormpy/src/helpers.h @@ -0,0 +1,29 @@ +/* + * helpers.h + * + * Created on: 16 Apr 2016 + * Author: harold + */ + +#ifndef PYTHON_HELPERS_H_ +#define PYTHON_HELPERS_H_ + +#include <sstream> +#include <string> + +/** + * Helper function to get a string out of the stream operator. + * Used for __str__ functions. + */ +template<typename T> +std::string streamToString(T const & t) { + std::stringstream ss; + ss << t; + return ss.str(); +} + +// Be warned: Enabling something like this will break everything about Monomial, +// as to Python the shared_ptr (Arg) IS the Monomial +// //PYBIND11_DECLARE_HOLDER_TYPE(T, std::shared_ptr<T>); + +#endif /* PYTHON_HELPERS_H_ */ diff --git a/stormpy/src/info/common.h b/stormpy/src/info/common.h new file mode 100644 index 000000000..0b0007d5c --- /dev/null +++ b/stormpy/src/info/common.h @@ -0,0 +1,7 @@ +#ifndef PYTHON_INFO_COMMON_H_ +#define PYTHON_INFO_COMMON_H_ + +//toString +#include "src/helpers.h" + +#endif /* PYTHON_INFO_COMMON_H_ */ diff --git a/stormpy/src/info/info.cpp b/stormpy/src/info/info.cpp new file mode 100644 index 000000000..a9defcab3 --- /dev/null +++ b/stormpy/src/info/info.cpp @@ -0,0 +1,13 @@ +#include "info.h" + +#include "common.h" +#include <src/utility/storm-version.h> + +void define_info(py::module& m) { + py::class_<storm::utility::StormVersion>(m, "Version") + + .def("short", &storm::utility::StormVersion::shortVersionString) + .def("long", &storm::utility::StormVersion::longVersionString) + .def("build_info", &storm::utility::StormVersion::buildInfo) + ; +} diff --git a/stormpy/src/info/info.h b/stormpy/src/info/info.h new file mode 100644 index 000000000..21b599f03 --- /dev/null +++ b/stormpy/src/info/info.h @@ -0,0 +1,8 @@ +#ifndef PYTHON_INFO_INFO_H_ +#define PYTHON_INFO_INFO_H_ + +#include "src/common.h" + +void define_info(py::module& m); + +#endif /* PYTHON_INFO_INFO_H_ */ diff --git a/stormpy/src/mod_core.cpp b/stormpy/src/mod_core.cpp new file mode 100644 index 000000000..a4fd9a438 --- /dev/null +++ b/stormpy/src/mod_core.cpp @@ -0,0 +1,9 @@ +#include "common.h" + +#include "core/core.h" + +PYBIND11_PLUGIN(core) { + py::module m("core"); + define_core(m); + return m.ptr(); +} diff --git a/stormpy/src/mod_info.cpp b/stormpy/src/mod_info.cpp new file mode 100644 index 000000000..4f57dac4b --- /dev/null +++ b/stormpy/src/mod_info.cpp @@ -0,0 +1,10 @@ +#include "common.h" +#include "helpers.h" + +#include "info/info.h" + +PYBIND11_PLUGIN(info) { + py::module m("stormpy.info", "stormpy info handling"); + define_info(m); + return m.ptr(); +} diff --git a/stormpy/__init__.py b/stormpy_old/__init__.py similarity index 100% rename from stormpy/__init__.py rename to stormpy_old/__init__.py diff --git a/stormpy/core/__init__.py b/stormpy_old/core/__init__.py similarity index 100% rename from stormpy/core/__init__.py rename to stormpy_old/core/__init__.py diff --git a/stormpy/expressions/__init__.py b/stormpy_old/expressions/__init__.py similarity index 100% rename from stormpy/expressions/__init__.py rename to stormpy_old/expressions/__init__.py diff --git a/stormpy/info/__init__.py b/stormpy_old/info/__init__.py similarity index 100% rename from stormpy/info/__init__.py rename to stormpy_old/info/__init__.py diff --git a/stormpy/logic/__init__.py b/stormpy_old/logic/__init__.py similarity index 100% rename from stormpy/logic/__init__.py rename to stormpy_old/logic/__init__.py