diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f8fa79ce44506ce36ef89bb431de03959c15974..4a2f6f6f71985a019f8b68b704ff247bcb09ca01 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,10 @@ -cmake_minimum_required (VERSION 3.20 FATAL_ERROR) +cmake_minimum_required (VERSION 3.26 FATAL_ERROR) -project (VAPython LANGUAGES CXX C) +project ( + VAPython + LANGUAGES CXX C + VERSION 2023.0 +) set (CMAKE_DEBUG_POSTFIX "-d") @@ -14,81 +18,29 @@ if (CMAKE_GENERATOR MATCHES "Visual Studio") set_property (GLOBAL PROPERTY USE_FOLDERS ON) endif () -# If build outside of VA project, eg via pip, ... -if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) - # ... build dependecies static so a single file contains everything needed. - set (BUILD_SHARED_LIBS OFF) - - # Additionally, download all dependencies. - set (CPM_DOWNLOAD_VERSION 0.32.2) - set (CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake") - - if (NOT (EXISTS ${CPM_DOWNLOAD_LOCATION})) - message (STATUS "Downloading CPM.cmake") - file (DOWNLOAD https://github.com/TheLartians/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake - ${CPM_DOWNLOAD_LOCATION} - ) - else (NOT (EXISTS ${CPM_DOWNLOAD_LOCATION})) - message ("CPM already exists, do not need to download") - endif (NOT (EXISTS ${CPM_DOWNLOAD_LOCATION})) - - include (${CPM_DOWNLOAD_LOCATION}) - - if (NOT TARGET VABase) - CPMAddPackage ( - NAME VABase - GIT_REPOSITORY https://git.rwth-aachen.de/ita/VABase - GIT_TAG master - ) - endif () - - if (NOT TARGET VANet) - CPMAddPackage ( - NAME VANet - GIT_REPOSITORY https://git.rwth-aachen.de/ita/VANet - GIT_TAG master - ) - endif () -endif () +CPMAddPackage ( + NAME python-cmake-wheel + GITHUB_REPOSITORY Klebert-Engineering/python-cmake-wheel + GIT_TAG main + DOWNLOAD_ONLY TRUE +) -if (PYTHON_SETUP_PY_VERSION) - list (APPEND PYTHON_SETUP_PY_VERSION EXACT) - message("${PYTHON_SETUP_PY_VERSION}") -endif () +list (INSERT CMAKE_MODULE_PATH 0 CMAKE_MODULE_PATH ${python-cmake-wheel_SOURCE_DIR}) -find_package (Python ${PYTHON_SETUP_PY_VERSION} REQUIRED COMPONENTS Interpreter Development) +include (python-wheel) -# --- Version --- -# get the version from setup.py -execute_process ( - COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/setup.py --version OUTPUT_VARIABLE VAPython_version -) -string (REGEX MATCHALL "([0-9]+)\\.([0-9]+)" _output ${VAPython_version}) -unset (_output) - -# use the result to set the project version -set (PROJECT_VERSION ${CMAKE_MATCH_0}) -set (PROJECT_VERSION_MAJOR ${CMAKE_MATCH_1}) -set (PROJECT_VERSION_MINOR ${CMAKE_MATCH_2}) - -# set the project version in cache for installation and packaging only -if (DEV_HELPERS) - set ( - ${PROJECT_NAME}_VERSION - ${PROJECT_VERSION} - CACHE INTERNAL "Cache entry of the project versions" - ) -endif () +find_package (Python REQUIRED COMPONENTS Interpreter Development.SABIModule) # Add target 'va', the project name is *not* used here, so in python the module is called 'va'. python_add_library ( ${PROJECT_NAME} MODULE + USE_SABI + 3.8 + WITH_SOABI src/vasingleton.cpp src/vasingletondoc.hpp src/vasingletonmethods.hpp - MANIFEST.in - setup.py ) add_library (VA::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) @@ -103,66 +55,78 @@ if (NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) set_property (TARGET ${PROJECT_NAME} PROPERTY FOLDER "Bindings/VA") endif () -# Remove the debug postfix, so the module always has the same name. Also set the output dir to bin, so if shared build is enabled, the module can find all the dlls. -set_target_properties (${PROJECT_NAME} PROPERTIES DEBUG_POSTFIX "" OUTPUT_NAME "va" - LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/$<CONFIG>/bin") - -# Only run this, if we are not building from setup.py -if (NOT PYTHON_SETUP_PY_BUILD) - - execute_process (COMMAND py --list OUTPUT_VARIABLE python_versions) - string (REGEX MATCHALL "([0-9]+\\.[0-9]+)" python_versions ${python_versions}) - - add_custom_target (${PROJECT_NAME}_wheel ALL) - - foreach (py_version ${python_versions}) - add_custom_command ( - TARGET ${PROJECT_NAME}_wheel - POST_BUILD - COMMAND py -${py_version} setup.py bdist_wheel - WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}" - COMMENT "Running distutils for version ${py_version}" - VERBATIM - ) - endforeach () - - set_property (TARGET ${PROJECT_NAME}_wheel PROPERTY FOLDER "Bindings/VA") - - # ---Install--- - - # prepare the install folder name - math (EXPR RELEASE_LETTER "${PROJECT_VERSION_MINOR}+97") - string (ASCII ${RELEASE_LETTER} RELEASE_LETTER) - set (VA_PYTHON_OUTPUT_FOLDER "VAPython_v${PROJECT_VERSION_MAJOR}${RELEASE_LETTER}") - - # Readme - install ( - FILES "README.md" - DESTINATION ${VA_PYTHON_OUTPUT_FOLDER} - COMPONENT ${PROJECT_NAME} - ) - - # Wheel files for installation on user machine - install ( - DIRECTORY "dist/" - DESTINATION ${VA_PYTHON_OUTPUT_FOLDER} - COMPONENT ${PROJECT_NAME} - FILES_MATCHING - PATTERN "*.whl" - ) - - # Tests - install ( - DIRECTORY "tests" - DESTINATION ${VA_PYTHON_OUTPUT_FOLDER} - COMPONENT ${PROJECT_NAME} - ) - - # Examples - install ( - DIRECTORY "examples" - DESTINATION ${VA_PYTHON_OUTPUT_FOLDER} - COMPONENT ${PROJECT_NAME} - ) +# Remove the debug postfix, so the module always has the same name. Also set the output dir to bin, so if shared build +# is enabled, the module can find all the dlls. +set_target_properties ( + ${PROJECT_NAME} PROPERTIES DEBUG_POSTFIX "" LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/$<CONFIG>/bin" +) -endif () +set (WHEEL_DEPLOY_DIRECTORY "${CMAKE_BINARY_DIR}/python_wheels") + +add_wheel ( + ${PROJECT_NAME} + VERSION + ${PROJECT_VERSION} + AUTHOR + "Institute for Hearing Technology and Acoustics (IHTA), RWTH Aachen University" + URL + "https://www.virtualacoustics.org" + LICENSE_PATH + ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md + PYTHON_REQUIRES + ">=3.8" + DESCRIPTION + "Virtual Acoustics (VA) singleton interface" + DEPLOY_FILES + "" + TARGET_DEPENDENCIES + VA::VABase # VANet is now static, not needed here. + MODULE_DEPENDENCIES + "" +) + +file (WRITE ${CMAKE_CURRENT_BINARY_DIR}/setup.cfg "[bdist_wheel]\npy_limited_api = cp38") + +file (READ ${CMAKE_CURRENT_BINARY_DIR}/setup.py setup_CONTENT) +string (REGEX REPLACE "(sources=\\[\\])" "\\1, py_limited_api=True" setup_CONTENT "${setup_CONTENT}") # +file (WRITE ${CMAKE_CURRENT_BINARY_DIR}/setup.py ${setup_CONTENT}) + +set_property (TARGET ${PROJECT_NAME}-copy-files ${PROJECT_NAME}-setup-py PROPERTY FOLDER "Bindings/VA") +set_property (TARGET wheel PROPERTY FOLDER "Bindings") + +# ---Install--- + +# prepare the install folder name +math (EXPR RELEASE_LETTER "${PROJECT_VERSION_MINOR}+97") +string (ASCII ${RELEASE_LETTER} RELEASE_LETTER) +set (VA_PYTHON_OUTPUT_FOLDER "VAPython_v${PROJECT_VERSION_MAJOR}${RELEASE_LETTER}") + +# Readme +install ( + FILES "README.md" + DESTINATION ${VA_PYTHON_OUTPUT_FOLDER} + COMPONENT ${PROJECT_NAME} +) + +# Wheel files for installation on user machine +install ( + DIRECTORY ${WHEEL_DEPLOY_DIRECTORY}/ + DESTINATION ${VA_PYTHON_OUTPUT_FOLDER} + COMPONENT ${PROJECT_NAME} + FILES_MATCHING + PATTERN "*.whl" +) + +# Tests +install ( + DIRECTORY "tests" + DESTINATION ${VA_PYTHON_OUTPUT_FOLDER} + COMPONENT ${PROJECT_NAME} +) + +# Examples +install ( + DIRECTORY "examples" + DESTINATION ${VA_PYTHON_OUTPUT_FOLDER} + COMPONENT ${PROJECT_NAME} +) diff --git a/LICENSE.md b/LICENSE.md index 9ad1e34fcd0aae76ae73ca0ca3a02fde302dd64b..fa64b037c0d2d630d0a0bb95332d5e634c083aed 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,4 +1,4 @@ -Copyright 2015-2022 Institute of Technical Acoustics (ITA), RWTH Aachen University +Copyright 2015-2023 Institute of Technical Acoustics (ITA), RWTH Aachen University Licensed under the Apache License, Version 2.0 (the "License"); you may not use files of this project except in compliance with the License. diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 063bdb96569c248b7fd257cb305833bb4611b6fc..0000000000000000000000000000000000000000 --- a/MANIFEST.in +++ /dev/null @@ -1,4 +0,0 @@ -include README.md LICENSE.md -include src/*.hpp -include src/*.cpp -recursive-include tests * diff --git a/README.md b/README.md index dec2aa3376ce99adfdc442ccb00e954b7e741ad5..726f58bb4c147bb711514eb0133ec2ef780bf8ef 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ VAPython contains is a C++ extension for the Python3 interpreter that provides a ### License -Copyright 2015-2022 Institute of Technical Acoustics (ITA), RWTH Aachen University +Copyright 2015-2023 Institute of Technical Acoustics (ITA), RWTH Aachen University Licensed under the Apache License, Version 2.0 (the "License"); you may not use files of this project except in compliance with the License. diff --git a/examples/jupyter/va_core_controller.ipynb b/examples/jupyter/va_core_controller.ipynb index 30bca6505ffec8c7f1fb9411979d4d99610eacab..e13f7aaab74d991d58f431b0af9ffca95dd5434d 100644 --- a/examples/jupyter/va_core_controller.ipynb +++ b/examples/jupyter/va_core_controller.ipynb @@ -33,7 +33,7 @@ "sys.path.append( '../../Lib/site-packages' )\n", "sys.path.append( '../../dist/Lib/site-packages' )\n", "import ipywidgets as widgets\n", - "import va\n", + "import VAPython as va\n", "if not va.connect() :\n", " raise 'Could not connect to local VA server'\n", "else :\n", diff --git a/examples/jupyter/va_experimental_renderer_example.ipynb b/examples/jupyter/va_experimental_renderer_example.ipynb index c945578def6d28aa0783b64a8a7a64ed517dbb98..8042b565de9aca10d1d3c993f06d7a77870384f3 100644 --- a/examples/jupyter/va_experimental_renderer_example.ipynb +++ b/examples/jupyter/va_experimental_renderer_example.ipynb @@ -37,7 +37,7 @@ "#sys.path.append( '../../Lib/site-packages' )\n", "sys.path.append( '../../dist/Lib/site-packages' )\n", "import ipywidgets as widgets\n", - "import va\n", + "import VAPython as va\n", "if not va.connect() :\n", " raise 'Could not connect to local VA server'\n", "else :\n", diff --git a/examples/jupyter/va_notebook_example.ipynb b/examples/jupyter/va_notebook_example.ipynb index 7536198be2971cf6eef4abdbbce93464c3ff3bd5..44d826fb2cf09c08c285193d20a54a4fb3e7f25e 100644 --- a/examples/jupyter/va_notebook_example.ipynb +++ b/examples/jupyter/va_notebook_example.ipynb @@ -40,7 +40,7 @@ "metadata": {}, "outputs": [], "source": [ - "import va" + "import VAPython as va" ] }, { diff --git a/examples/jupyter/va_scene_controller.ipynb b/examples/jupyter/va_scene_controller.ipynb index 6d6c78cce5f57bdd476d958d22007bba7e58acc3..868c016579c2040791cedaa249270c9a4bf99b97 100644 --- a/examples/jupyter/va_scene_controller.ipynb +++ b/examples/jupyter/va_scene_controller.ipynb @@ -26,7 +26,7 @@ "sys.path.append( '../../Lib/site-packages' )\n", "sys.path.append( '../../dist/Lib/site-packages' )\n", "import ipywidgets as widgets\n", - "import va\n", + "import VAPython as va\n", "if not va.connect() :\n", " raise 'Could not connect to VA server on localhost'" ] diff --git a/examples/jupyter/va_signal_sources_controller.ipynb b/examples/jupyter/va_signal_sources_controller.ipynb index 1b9b125b863b204a93e86d1f9920171318bb469f..9757729b2dfa83d514a62168c177792f5c2483b0 100644 --- a/examples/jupyter/va_signal_sources_controller.ipynb +++ b/examples/jupyter/va_signal_sources_controller.ipynb @@ -34,7 +34,7 @@ "import sys\n", "sys.path.append( '../../Lib/site-packages' )\n", "import ipywidgets as widgets\n", - "import va\n", + "import VAPython as va\n", "if not va.connect() :\n", " raise Exception( 'Could not connect to local VA server' )" ] diff --git a/examples/jupyter/va_simple_acoustic_scene.ipynb b/examples/jupyter/va_simple_acoustic_scene.ipynb index 9acb3c67a99ae7b0122ea82afc4ef98de65d2432..18fd9bb31f9b7c846a4e81caea2e21c663f24a9f 100644 --- a/examples/jupyter/va_simple_acoustic_scene.ipynb +++ b/examples/jupyter/va_simple_acoustic_scene.ipynb @@ -27,7 +27,7 @@ "sys.path.append( '../../dist/Lib/site-packages' ) # dev\n", "import os\n", "print( 'Current working directory:', os.getcwd() )\n", - "import va\n", + "import VAPython as va\n", "print( 'Successfully loaded VA Python extension')" ] }, diff --git a/examples/va_example_simple.py b/examples/va_example_simple.py index 367243e606c4724422c6f1849d123131258d20df..5fbd34970f7a9b8d56ce3db8562a883201ce2316 100644 --- a/examples/va_example_simple.py +++ b/examples/va_example_simple.py @@ -2,7 +2,7 @@ import os current_exec_dir = os.getcwd() # Make sure you installed the va module -import va +import VAPython as va va.connect() # localhost va.reset() diff --git a/setup.py b/setup.py deleted file mode 100644 index add9bd3b50d8990b768c75b94431fad50bdab191..0000000000000000000000000000000000000000 --- a/setup.py +++ /dev/null @@ -1,149 +0,0 @@ -import os -import re -import subprocess -import sys -import shutil -from pathlib import Path -from warnings import warn - -from setuptools import Extension, setup -from setuptools.command.build_ext import build_ext - -# Convert distutils Windows platform specifiers to CMake -A arguments -PLAT_TO_CMAKE = { - "win32": "Win32", - "win-amd64": "x64", - "win-arm32": "ARM", - "win-arm64": "ARM64", -} - - -# A CMakeExtension needs a sourcedir instead of a file list. -# The name must be the _single_ output extension from the CMake build. -# If you need multiple extensions, see scikit-build. -class CMakeExtension(Extension): - def __init__(self, name, sourcedir=""): - Extension.__init__(self, name, sources=[]) - self.sourcedir = os.path.abspath(sourcedir) - - -class CMakeBuild(build_ext): - def build_extension(self, ext): - # check for CMake in Path, if not and on windows try to find it in programs directory - if shutil.which('cmake') == None and sys.platform == 'win32': - - possibleExes = list(Path('C:/').glob('*/*cmake*/bin/cmake.exe')) - - if not possibleExes and possibleExes[0].is_file: - os.environ['PATH'] += ';' + str(possibleExes[0].absolute()) - warn('Did not find CMake in PATH, adding it manually for this script') - - # check again for CMake in Path - if shutil.which('cmake') == None: - raise RuntimeError('CMake not found in PATH') - - extdir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name))) - - # required for auto-detection & inclusion of auxiliary "native" libs - if not extdir.endswith(os.path.sep): - extdir += os.path.sep - - debug = int(os.environ.get("DEBUG", 0)) if self.debug is None else self.debug - cfg = "Debug" if debug else "Release" - - # CMake lets you override the generator - we need to check this. - # Can be set with Conda-Build, for example. - cmake_generator = os.environ.get("CMAKE_GENERATOR", "") - - # Set Python_EXECUTABLE instead if you use PYBIND11_FINDPYTHON - # EXAMPLE_VERSION_INFO shows you how to pass a value into the C++ code - # from Python. - cmake_args = [ - f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={extdir}", - f"-DPYTHON_EXECUTABLE={sys.executable}", - f"-DCMAKE_BUILD_TYPE={cfg}", # not used on MSVC, but no harm - ] - build_args = [] - # Adding CMake arguments set as environment variable - # (needed e.g. to build for ARM OSx on conda-forge) - if "CMAKE_ARGS" in os.environ: - cmake_args += [item for item in os.environ["CMAKE_ARGS"].split(" ") if item] - - if self.compiler.compiler_type != "msvc": - # Using Ninja-build since it a) is available as a wheel and b) - # multithreads automatically. MSVC would require all variables be - # exported for Ninja to pick it up, which is a little tricky to do. - # Users can override the generator with CMAKE_GENERATOR in CMake - # 3.15+. - if not cmake_generator: - try: - import ninja # noqa: F401 - - cmake_args += ["-GNinja"] - except ImportError: - pass - - else: - - # Single config generators are handled "normally" - single_config = any(x in cmake_generator for x in {"NMake", "Ninja"}) - - # CMake allows an arch-in-generator style for backward compatibility - contains_arch = any(x in cmake_generator for x in {"ARM", "Win64"}) - - # Specify the arch if using MSVC generator, but only if it doesn't - # contain a backward-compatibility arch spec already in the - # generator name. - if not single_config and not contains_arch: - cmake_args += ["-A", PLAT_TO_CMAKE[self.plat_name]] - - # Multi-config generators have a different way to specify configs - if not single_config: - cmake_args += [ - f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{cfg.upper()}={extdir}" - ] - build_args += ["--config", cfg] - - if sys.platform.startswith("darwin"): - # Cross-compile support for macOS - respect ARCHFLAGS if set - archs = re.findall(r"-arch (\S+)", os.environ.get("ARCHFLAGS", "")) - if archs: - cmake_args += ["-DCMAKE_OSX_ARCHITECTURES={}".format(";".join(archs))] - - # Set CMAKE_BUILD_PARALLEL_LEVEL to control the parallel build level - # across all generators. - if "CMAKE_BUILD_PARALLEL_LEVEL" not in os.environ: - # self.parallel is a Python 3 only way to set parallel jobs by hand - # using -j in the build_ext call, not supported by pip or PyPA-build. - if hasattr(self, "parallel") and self.parallel: - # CMake 3.12+ only. - build_args += [f"-j{self.parallel}"] - - if not os.path.exists(self.build_temp): - os.makedirs(self.build_temp) - - # cmake_args += ["-DPYTHON_SETUP_PY_BUILD=ON"] - cmake_args += ["-DPYTHON_SETUP_PY_BUILD=ON", "-DPYTHON_SETUP_PY_VERSION={}.{}".format(sys.version_info[0],sys.version_info[1])] - - subprocess.check_call( - ["cmake", ext.sourcedir] + cmake_args, cwd=self.build_temp - ) - subprocess.check_call( - ["cmake", "--build", "."] + build_args, cwd=self.build_temp - ) - -setup( - name="va", - description = 'Virtual Acoustics (VA) singleton interface', - version="2022.0", - author="Institute for Hearing Technology and Acoustics (IHTA), RWTH Aachen University", - author_email="post@akustik.rwth-aachen.de", - url = 'https://www.virtualacoustics.org', - long_description = ''' -Virtual Acoustics (VA) is a real-time auralization framework for Virtual Reality. This module is an interface to interact with a VA server. -''', - license = "Copyright 2017-2021. Apache License Version 2.0", - ext_modules=[CMakeExtension("va")], - cmdclass={"build_ext": CMakeBuild}, - python_requires=">=3.7", -) diff --git a/src/common.hpp b/src/common.hpp new file mode 100644 index 0000000000000000000000000000000000000000..c0f010344c406102d2434070b4601adf52ca0f56 --- /dev/null +++ b/src/common.hpp @@ -0,0 +1,20 @@ +#ifndef IW_VA_PYTHON_COMMON +#define IW_VA_PYTHON_COMMON + +// Temporarily "disable" debug to include Python. +// This is done, so that the Python debug libraries are not needed, even when building +// this module in debug mode. +#ifdef _DEBUG +# define TMP_DEBUG +# undef _DEBUG +// Fix msvc compiler issue error C2039: '_invalid_parameter': is not a member of '`global namespace'' +// See https://github.com/microsoft/STL/issues/2335#issuecomment-967293809 for more detail +# define _STL_CRT_SECURE_INVALID_PARAMETER( expr ) _CRT_SECURE_INVALID_PARAMETER( expr ) +#endif +#include <Python.h> +#ifdef TMP_DEBUG +# define _DEBUG +# undef TMP_DEBUG +#endif + +#endif \ No newline at end of file diff --git a/src/vasingleton.cpp b/src/vasingleton.cpp index 8a488ee90a98b41cb53b16aa88b0aa49a035a3fb..b3914c981eac6b20d45260bc27cd0a20320874f7 100644 --- a/src/vasingleton.cpp +++ b/src/vasingleton.cpp @@ -4,26 +4,14 @@ * VVV VVV A Virtual Acoustics (VA) | http://www.virtualacoustics.org * VVV VVV AAA Licensed under the Apache License, Version 2.0 * VVV VVV AAA - * VVV VVV AAA Copyright 2015-2022 + * VVV VVV AAA Copyright 2015-2023 * VVVVVV AAA Institute of Technical Acoustics (ITA) * VVVV AAA RWTH Aachen University * * -------------------------------------------------------------------------------------------- */ -// Temporarily "disable" debug to include Python. -// This is done, so that the Python debug libraries are not needed, even when building -// this module in debug mode. -#ifdef _DEBUG -# define TMP_DEBUG -# undef _DEBUG -#endif -#include <Python.h> -#ifdef TMP_DEBUG -# define _DEBUG -# undef TMP_DEBUG -#endif - +#include "common.hpp" #include "vasingletondoc.hpp" // All Python to VA methods. Also pulls in g_pVAError (Python error trace instance) @@ -217,7 +205,7 @@ static struct PyMethodDef va_methods[] = { static struct PyModuleDef vamoduledef = { PyModuleDef_HEAD_INIT, "va", module_doc, -1, va_methods, NULL, NULL, NULL, NULL }; -PyMODINIT_FUNC PyInit_va( void ) +PyMODINIT_FUNC PyInit_VAPython( void ) { PyObject* pModule = PyModule_Create( &vamoduledef ); g_pVAError = PyErr_NewException( "va.error", NULL, NULL ); diff --git a/src/vasingletondoc.hpp b/src/vasingletondoc.hpp index 5d7cdc8ec7add49f42fd9b04872b6bd87caec354..f9aafeddbeb00c6ead24bfbbc445f8349962724b 100644 --- a/src/vasingletondoc.hpp +++ b/src/vasingletondoc.hpp @@ -10,19 +10,10 @@ * * -------------------------------------------------------------------------------------------- */ +#ifndef IW_VA_PYTHON_DOC +#define IW_VA_PYTHON_DOC -// Temporarily "disable" debug to include Python. -// This is done, so that the Python debug libraries are not needed, even when building -// this module in debug mode. -#ifdef _DEBUG -# define TMP_DEBUG -# undef _DEBUG -#endif -#include <Python.h> -#ifdef TMP_DEBUG -# define _DEBUG -# undef TMP_DEBUG -#endif +#include "common.hpp" PyDoc_STRVAR( module_doc, "connect(server, port) - connect to a VA server at given server and listening port\n" @@ -42,3 +33,5 @@ PyDoc_STRVAR( connect_doc, " Remote server IP.\n" " port\n" " TCP/IP listening port, usually 12340." ); + +#endif \ No newline at end of file diff --git a/src/vasingletonmethods.hpp b/src/vasingletonmethods.hpp index aa024f44436c5cf760bc168df51730dc507b6f8d..e681ce3b380c7fc658b4931681592759d0197699 100644 --- a/src/vasingletonmethods.hpp +++ b/src/vasingletonmethods.hpp @@ -10,30 +10,22 @@ * * -------------------------------------------------------------------------------------------- */ +#ifndef IW_VA_PYTHON_METHODS +#define IW_VA_PYTHON_METHODS -// Temporarily "disable" debug to include Python. -// This is done, so that the Python debug libraries are not needed, even when building -// this module in debug mode. -#ifdef _DEBUG -# define TMP_DEBUG -# undef _DEBUG -#endif -#include <Python.h> -#ifdef TMP_DEBUG -# define _DEBUG -# undef TMP_DEBUG -#endif +#include "common.hpp" #include <VA.h> #include <VANet.h> -#include <string.h> +#include <string> // If you want to extend the va Python pSelf interface, also add // the function to the va_methods table in vasingleton.cpp - otherwise they will not show up. // Documentation goes into vasingletondoc.hpp -static IVANetClient* g_pVANetClient = nullptr; //!< Static pointer to VANetClient instance -static PyObject* g_pVAError = nullptr; //!< Static pointer to error instance +static std::unique_ptr<IVANetClient> g_pVANetClient = nullptr; //!< Static pointer to VANetClient instance +// static IVANetClient* g_pVANetClient = nullptr; //!< Static pointer to VANetClient instance +static PyObject* g_pVAError = nullptr; //!< Static pointer to error instance // Ugly definitions to ease try-catching VA exceptions #define VAPY_REQUIRE_CONN_TRY \ @@ -79,7 +71,7 @@ PyObject* ConvertFloatVectorToPythonList( const std::vector<float> vfValues ) { PyObject* pList = PyList_New( vfValues.size( ) ); - for( Py_ssize_t i = 0; i < PyList_GET_SIZE( pList ); i++ ) + for( Py_ssize_t i = 0; i < PyList_Size( pList ); i++ ) PyList_SetItem( pList, i, PyLong_FromDouble( vfValues[i] ) ); return pList; @@ -89,7 +81,7 @@ PyObject* ConvertDoubleVectorToPythonList( const std::vector<double> vdValues ) { PyObject* pList = PyList_New( vdValues.size( ) ); - for( Py_ssize_t i = 0; i < PyList_GET_SIZE( pList ); i++ ) + for( Py_ssize_t i = 0; i < PyList_Size( pList ); i++ ) PyList_SetItem( pList, i, PyLong_FromDouble( vdValues[i] ) ); return pList; @@ -99,7 +91,7 @@ PyObject* ConvertIntVectorToPythonList( const std::vector<int> viValues ) { PyObject* pList = PyList_New( viValues.size( ) ); - for( Py_ssize_t i = 0; i < PyList_GET_SIZE( pList ); i++ ) + for( Py_ssize_t i = 0; i < PyList_Size( pList ); i++ ) PyList_SetItem( pList, i, PyLong_FromLong( viValues[i] ) ); return pList; @@ -276,7 +268,7 @@ static PyObject* connect( PyObject*, PyObject* pArgs, PyObject* pKeywordTuple ) std::string sServerIP = pcServerIP ? std::string( pcServerIP ) : "localhost"; - if( IVANetClient::VA_NO_ERROR == g_pVANetClient->Initialize( sServerIP, iServerPort ) ) + if( g_pVANetClient->Initialize( sServerIP, iServerPort ) ) return PyBool_FromLong( 1 ); PyErr_SetString( PyExc_ConnectionError, std::string( "Could not connect to " + sServerIP + " on " + std::to_string( (long)iServerPort ) ).c_str( ) ); @@ -303,8 +295,7 @@ static PyObject* reset( PyObject*, PyObject* ) { VAPY_REQUIRE_CONN_TRY; g_pVANetClient->GetCoreInstance( )->Reset( ); - Py_INCREF( Py_None ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -344,7 +335,7 @@ static PyObject* call_module( PyObject*, PyObject* pArgs, PyObject* pKeywordTupl VAPY_REQUIRE_CONN_TRY; static char* pKeyWordList[] = { "module_name", "arguments_dict", NULL }; - const char* pcFormat = "sO!:call_module"; + const char* pcFormat = "sO:call_module"; char* pcModuleName = nullptr; PyObject* pArgumentsDict = nullptr; @@ -394,8 +385,7 @@ static PyObject* lock_update( PyObject*, PyObject* ) { VAPY_REQUIRE_CONN_TRY; g_pVANetClient->GetCoreInstance( )->LockUpdate( ); - Py_INCREF( Py_None ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -550,7 +540,7 @@ static PyObject* set_sound_source_enabled( PyObject*, PyObject* pArgs, PyObject* return NULL; g_pVANetClient->GetCoreInstance( )->SetSoundSourceEnabled( iID, bEnabled ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -614,7 +604,7 @@ static PyObject* set_sound_source_signal_source( PyObject*, PyObject* pArgs, PyO std::string sSIgnalSourceID = pcSignalSourceID ? std::string( pcSignalSourceID ) : ""; g_pVANetClient->GetCoreInstance( )->SetSoundSourceSignalSource( iID, sSIgnalSourceID ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -630,7 +620,7 @@ static PyObject* remove_sound_source_signal_source( PyObject*, PyObject* pArgs, return NULL; g_pVANetClient->GetCoreInstance( )->RemoveSoundSourceSignalSource( iID ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -670,7 +660,7 @@ static PyObject* set_sound_source_auralization_mode( PyObject*, PyObject* pArgs, const int iAM = IVAInterface::ParseAuralizationModeStr( sAM, iCurrentAM ); g_pVANetClient->GetCoreInstance( )->SetSoundSourceAuralizationMode( iID, iAM ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -680,7 +670,7 @@ static PyObject* set_sound_source_parameters( PyObject*, PyObject* pArgs, PyObje VAPY_REQUIRE_CONN_TRY; static char* pKeyWordList[] = { "id", "parameters", NULL }; - const char* pcFormat = "iO!:set_sound_source_parameters"; + const char* pcFormat = "iO:set_sound_source_parameters"; long iID = -1; PyObject* pParameters = nullptr; if( !PyArg_ParseTupleAndKeywords( pArgs, pKeywordTuple, pcFormat, pKeyWordList, &iID, &pParameters ) ) @@ -688,7 +678,7 @@ static PyObject* set_sound_source_parameters( PyObject*, PyObject* pArgs, PyObje CVAStruct oParameters = ConvertPythonDictToVAStruct( pParameters ); g_pVANetClient->GetCoreInstance( )->SetSoundSourceParameters( iID, oParameters ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -699,7 +689,7 @@ static PyObject* get_sound_source_parameters( PyObject*, PyObject* pArgs, PyObje VAPY_REQUIRE_CONN_TRY; static char* pKeyWordList[] = { "id", NULL }; - const char* pcFormat = "io!:get_sound_source_parameters"; + const char* pcFormat = "iO:get_sound_source_parameters"; long iID = -1; PyObject* pParameters = nullptr; if( !PyArg_ParseTupleAndKeywords( pArgs, pKeywordTuple, pcFormat, pKeyWordList, &iID, &pParameters ) ) @@ -739,7 +729,7 @@ static PyObject* set_sound_source_directivity( PyObject*, PyObject* pArgs, PyObj return NULL; g_pVANetClient->GetCoreInstance( )->SetSoundSourceDirectivity( iID, iDirectivityID ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -771,7 +761,7 @@ static PyObject* set_sound_source_sound_power( PyObject*, PyObject* pArgs, PyObj return NULL; g_pVANetClient->GetCoreInstance( )->SetSoundSourceSoundPower( iID, dPower ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -788,7 +778,7 @@ static PyObject* set_sound_source_muted( PyObject*, PyObject* pArgs, PyObject* p return NULL; g_pVANetClient->GetCoreInstance( )->SetSoundSourceMuted( iID, bMuted ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -842,7 +832,7 @@ static PyObject* set_sound_source_position( PyObject*, PyObject* pArgs, PyObject return NULL; g_pVANetClient->GetCoreInstance( )->SetSoundSourcePosition( iID, v3Pos ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -878,7 +868,7 @@ static PyObject* set_sound_source_orientation_vu( PyObject*, PyObject* pArgs, Py return NULL; g_pVANetClient->GetCoreInstance( )->SetSoundSourceOrientationVU( iID, v3View, v3Up ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -890,7 +880,7 @@ static PyObject* get_sound_receiver_ids( PyObject*, PyObject* ) g_pVANetClient->GetCoreInstance( )->GetSoundReceiverIDs( viIDs ); PyObject* pIDList = PyList_New( viIDs.size( ) ); - for( Py_ssize_t i = 0; i < PyList_GET_SIZE( pIDList ); i++ ) + for( Py_ssize_t i = 0; i < PyList_Size( pIDList ); i++ ) PyList_SetItem( pIDList, i, PyLong_FromLong( viIDs[i] ) ); return pIDList; @@ -959,7 +949,7 @@ static PyObject* set_sound_receiver_enabled( PyObject*, PyObject* pArgs, PyObjec return NULL; g_pVANetClient->GetCoreInstance( )->SetSoundReceiverEnabled( iID, bEnabled ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -1029,7 +1019,7 @@ static PyObject* set_sound_receiver_auralization_mode( PyObject*, PyObject* pArg const int iAM = IVAInterface::ParseAuralizationModeStr( sAM, iCurrentAM ); g_pVANetClient->GetCoreInstance( )->SetSoundReceiverAuralizationMode( iID, iAM ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -1039,7 +1029,7 @@ static PyObject* set_sound_receiver_parameters( PyObject*, PyObject* pArgs, PyOb VAPY_REQUIRE_CONN_TRY; static char* pKeyWordList[] = { "id", "parameters", NULL }; - const char* pcFormat = "iO!:set_sound_receiver_parameters"; + const char* pcFormat = "iO:set_sound_receiver_parameters"; long iID = -1; PyObject* pParameters = nullptr; if( !PyArg_ParseTupleAndKeywords( pArgs, pKeywordTuple, pcFormat, pKeyWordList, &iID, &pParameters ) ) @@ -1047,7 +1037,7 @@ static PyObject* set_sound_receiver_parameters( PyObject*, PyObject* pArgs, PyOb CVAStruct oParameters = ConvertPythonDictToVAStruct( pParameters ); g_pVANetClient->GetCoreInstance( )->SetSoundReceiverParameters( iID, oParameters ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -1058,7 +1048,7 @@ static PyObject* get_sound_receiver_parameters( PyObject*, PyObject* pArgs, PyOb VAPY_REQUIRE_CONN_TRY; static char* pKeyWordList[] = { "id", NULL }; - const char* pcFormat = "io!:get_sound_receiver_parameters"; + const char* pcFormat = "iO:get_sound_receiver_parameters"; long iID = -1; PyObject* pParameters = nullptr; if( !PyArg_ParseTupleAndKeywords( pArgs, pKeywordTuple, pcFormat, pKeyWordList, &iID, &pParameters ) ) @@ -1099,7 +1089,7 @@ static PyObject* set_sound_receiver_directivity( PyObject*, PyObject* pArgs, PyO return NULL; g_pVANetClient->GetCoreInstance( )->SetSoundReceiverDirectivity( iID, iDirectivityID ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -1116,7 +1106,7 @@ static PyObject* set_sound_receiver_muted( PyObject*, PyObject* pArgs, PyObject* return NULL; g_pVANetClient->GetCoreInstance( )->SetSoundReceiverMuted( iID, bMuted ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -1171,7 +1161,7 @@ static PyObject* set_sound_receiver_position( PyObject*, PyObject* pArgs, PyObje return NULL; g_pVANetClient->GetCoreInstance( )->SetSoundReceiverPosition( iID, v3Pos ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -1206,7 +1196,7 @@ static PyObject* set_sound_receiver_orientation_vu( PyObject*, PyObject* pArgs, return NULL; g_pVANetClient->GetCoreInstance( )->SetSoundReceiverOrientationVU( iID, v3View, v3Up ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -1248,7 +1238,7 @@ static PyObject* set_sound_receiver_real_world_position( PyObject*, PyObject* pA VAVec3 v3PosDummy, v3View, v3Up; g_pVANetClient->GetCoreInstance( )->GetSoundReceiverRealWorldPositionOrientationVU( iID, v3PosDummy, v3View, v3Up ); g_pVANetClient->GetCoreInstance( )->SetSoundReceiverRealWorldPositionOrientationVU( iID, v3Pos, v3View, v3Up ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -1285,7 +1275,7 @@ static PyObject* set_sound_receiver_real_world_orientation_vu( PyObject*, PyObje VAVec3 v3Pos, v3View_dummy, v3Up_dummy; g_pVANetClient->GetCoreInstance( )->GetSoundReceiverRealWorldPositionOrientationVU( iID, v3Pos, v3View_dummy, v3Up_dummy ); g_pVANetClient->GetCoreInstance( )->SetSoundReceiverRealWorldPositionOrientationVU( iID, v3Pos, v3View, v3Up ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -1313,7 +1303,7 @@ static PyObject* create_signal_source_prototype_from_parameters( PyObject*, PyOb VAPY_REQUIRE_CONN_TRY; static char* pKeyWordList[] = { "parameters", "name", NULL }; - const char* pcFormat = "O!|s:create_signal_source_prototype_from_parameters"; + const char* pcFormat = "O|s:create_signal_source_prototype_from_parameters"; PyObject* pParameters = nullptr; char* pcName = nullptr; if( !PyArg_ParseTupleAndKeywords( pArgs, pKeywordTuple, pcFormat, pKeyWordList, &pParameters, &pcName ) ) @@ -1386,7 +1376,7 @@ static PyObject* create_signal_source_engine( PyObject*, PyObject* pArgs, PyObje VAPY_REQUIRE_CONN_TRY; static char* pKeyWordList[] = { "name", NULL }; - const char* pcFormat = "O!|s:create_signal_source_engine"; + const char* pcFormat = "O|s:create_signal_source_engine"; PyObject* pParameters = nullptr; char* pcName = nullptr; if( !PyArg_ParseTupleAndKeywords( pArgs, pKeywordTuple, pcFormat, pKeyWordList, &pParameters, &pcName ) ) @@ -1405,7 +1395,7 @@ static PyObject* create_signal_source_machine( PyObject*, PyObject* pArgs, PyObj VAPY_REQUIRE_CONN_TRY; static char* pKeyWordList[] = { "name", NULL }; - const char* pcFormat = "O!|s:create_signal_source_machine"; + const char* pcFormat = "O|s:create_signal_source_machine"; PyObject* pParameters = nullptr; char* pcName = nullptr; if( !PyArg_ParseTupleAndKeywords( pArgs, pKeywordTuple, pcFormat, pKeyWordList, &pParameters, &pcName ) ) @@ -1529,7 +1519,7 @@ static PyObject* set_signal_source_buffer_playback_action( PyObject*, PyObject* std::string sSignalSource = pcSignalSource ? std::string( pcSignalSource ) : ""; g_pVANetClient->GetCoreInstance( )->SetSignalSourceBufferPlaybackAction( sSignalSource, iAction ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -1550,7 +1540,7 @@ static PyObject* set_signal_source_buffer_playback_action_str( PyObject*, PyObje std::string sSignalSource = pcSignalSource ? std::string( pcSignalSource ) : ""; g_pVANetClient->GetCoreInstance( )->SetSignalSourceBufferPlaybackAction( sSignalSource, iAction ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -1568,7 +1558,7 @@ static PyObject* set_signal_source_buffer_playback_position( PyObject*, PyObject std::string sSignalSource = pcSignalSource ? std::string( pcSignalSource ) : ""; g_pVANetClient->GetCoreInstance( )->SetSignalSourceBufferPlaybackPosition( sSignalSource, iPosition ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -1602,7 +1592,7 @@ static PyObject* set_signal_source_buffer_looping( PyObject*, PyObject* pArgs, P std::string sSignalSource = pcSignalSource ? std::string( pcSignalSource ) : ""; g_pVANetClient->GetCoreInstance( )->SetSignalSourceBufferLooping( sSignalSource, bEnabled ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -1619,7 +1609,7 @@ static PyObject* set_signal_source_machine_start_machine( PyObject*, PyObject* p std::string sSignalSource = pcSignalSource ? std::string( pcSignalSource ) : ""; g_pVANetClient->GetCoreInstance( )->SetSignalSourceMachineStartMachine( sSignalSource ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -1636,7 +1626,7 @@ static PyObject* set_signal_source_machine_halt_machine( PyObject*, PyObject* pA std::string sSignalSource = pcSignalSource ? std::string( pcSignalSource ) : ""; g_pVANetClient->GetCoreInstance( )->SetSignalSourceMachineHaltMachine( sSignalSource ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -1673,7 +1663,7 @@ static PyObject* set_signal_source_machine_speed( PyObject*, PyObject* pArgs, Py std::string sSignalSource = pcSignalSource ? std::string( pcSignalSource ) : ""; g_pVANetClient->GetCoreInstance( )->SetSignalSourceMachineSpeed( sSignalSource, dSpeed ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -1711,7 +1701,7 @@ static PyObject* set_signal_source_machine_start_file( PyObject*, PyObject* pArg std::string sPath = pcPath ? std::string( pcPath ) : ""; g_pVANetClient->GetCoreInstance( )->SetSignalSourceMachineStartFile( sSignalSource, sPath ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -1731,7 +1721,7 @@ static PyObject* set_signal_source_machine_idle_file( PyObject*, PyObject* pArgs std::string sPath = pcPath ? std::string( pcPath ) : ""; g_pVANetClient->GetCoreInstance( )->SetSignalSourceMachineIdleFile( sSignalSource, sPath ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -1751,7 +1741,7 @@ static PyObject* set_signal_source_machine_stop_file( PyObject*, PyObject* pArgs std::string sPath = pcPath ? std::string( pcPath ) : ""; g_pVANetClient->GetCoreInstance( )->SetSignalSourceMachineStopFile( sSignalSource, sPath ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -1761,7 +1751,7 @@ static PyObject* get_signal_source_parameters( PyObject*, PyObject* pArgs, PyObj VAPY_REQUIRE_CONN_TRY; static char* pKeyWordList[] = { "signalsource", "parameters", NULL }; - const char* pcFormat = "iO!:get_signal_source_parameters"; + const char* pcFormat = "iO:get_signal_source_parameters"; char* pcSignalSource = nullptr; PyObject* pParameters = nullptr; if( !PyArg_ParseTupleAndKeywords( pArgs, pKeywordTuple, pcFormat, pKeyWordList, &pcSignalSource, &pParameters ) ) @@ -1780,7 +1770,7 @@ static PyObject* set_signal_source_parameters( PyObject*, PyObject* pArgs, PyObj VAPY_REQUIRE_CONN_TRY; static char* pKeyWordList[] = { "id", NULL }; - const char* pcFormat = "io!:set_signal_source_parameters"; + const char* pcFormat = "iO:set_signal_source_parameters"; char* pcSignalSource = nullptr; PyObject* pParameters = nullptr; if( !PyArg_ParseTupleAndKeywords( pArgs, pKeywordTuple, pcFormat, pKeyWordList, &pcSignalSource, &pParameters ) ) @@ -1790,7 +1780,7 @@ static PyObject* set_signal_source_parameters( PyObject*, PyObject* pArgs, PyObj CVAStruct oParameters = ConvertPythonDictToVAStruct( pParameters ); g_pVANetClient->GetCoreInstance( )->SetSignalSourceParameters( sSignalSource, oParameters ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -1802,7 +1792,7 @@ static PyObject* get_sound_portal_ids( PyObject*, PyObject* ) g_pVANetClient->GetCoreInstance( )->GetSoundPortalIDs( viIDs ); PyObject* pIDList = PyList_New( viIDs.size( ) ); - for( Py_ssize_t i = 0; i < PyList_GET_SIZE( pIDList ); i++ ) + for( Py_ssize_t i = 0; i < PyList_Size( pIDList ); i++ ) PyList_SetItem( pIDList, i, PyLong_FromLong( viIDs[i] ) ); return pIDList; @@ -1838,7 +1828,7 @@ static PyObject* set_sound_portal_name( PyObject*, PyObject* pArgs, PyObject* pK std::string sName = pcName ? std::string( pcName ) : ""; g_pVANetClient->GetCoreInstance( )->SetSoundPortalName( iID, sName ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -1870,7 +1860,7 @@ static PyObject* set_sound_portal_enabled( PyObject*, PyObject* pArgs, PyObject* return NULL; g_pVANetClient->GetCoreInstance( )->SetSoundPortalEnabled( iID, bEnabled ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -1894,7 +1884,7 @@ static PyObject* set_homogeneous_medium_sound_speed( PyObject*, PyObject* pArgs, return NULL; g_pVANetClient->GetCoreInstance( )->SetHomogeneousMediumSoundSpeed( dSoundSpeed ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -1916,7 +1906,7 @@ static PyObject* set_homogeneous_medium_temperature( PyObject*, PyObject* pArgs, return NULL; g_pVANetClient->GetCoreInstance( )->SetHomogeneousMediumTemperature( dTemperature ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -1939,7 +1929,7 @@ static PyObject* set_homogeneous_medium_static_pressure( PyObject*, PyObject* pA return NULL; g_pVANetClient->GetCoreInstance( )->SetHomogeneousMediumStaticPressure( dStaticPressure ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -1962,7 +1952,7 @@ static PyObject* set_homogeneous_medium_relative_humidity( PyObject*, PyObject* return NULL; g_pVANetClient->GetCoreInstance( )->SetHomogeneousMediumRelativeHumidity( dRelativeHumidity ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -1992,7 +1982,7 @@ static PyObject* set_homogeneous_medium_shift_speed( PyObject*, PyObject* pArgs, return NULL; g_pVANetClient->GetCoreInstance( )->SetHomogeneousMediumShiftSpeed( v3ShiftSpeed ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -2002,7 +1992,7 @@ static PyObject* get_homogeneous_medium_parameters( PyObject*, PyObject* pArgs, VAPY_REQUIRE_CONN_TRY; static char* pKeyWordList[] = { "arguments", NULL }; - const char* pcFormat = "|O!:get_homogeneous_medium_parameters"; + const char* pcFormat = "|O:get_homogeneous_medium_parameters"; PyObject* pParamArgs = nullptr; if( !PyArg_ParseTupleAndKeywords( pArgs, pKeywordTuple, pcFormat, pKeyWordList, &pParamArgs ) ) return NULL; @@ -2019,7 +2009,7 @@ static PyObject* set_homogeneous_medium_parameters( PyObject*, PyObject* pArgs, VAPY_REQUIRE_CONN_TRY; static char* pKeyWordList[] = { "parameters", NULL }; - const char* pcFormat = "O!:set_homogeneous_medium_parameters"; + const char* pcFormat = "O:set_homogeneous_medium_parameters"; PyObject* pParameters = nullptr; if( !PyArg_ParseTupleAndKeywords( pArgs, pKeywordTuple, pcFormat, pKeyWordList, &pParameters ) ) return NULL; @@ -2027,7 +2017,7 @@ static PyObject* set_homogeneous_medium_parameters( PyObject*, PyObject* pArgs, CVAStruct oParameters = ConvertPythonDictToVAStruct( pParameters ); g_pVANetClient->GetCoreInstance( )->SetHomogeneousMediumParameters( oParameters ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -2081,7 +2071,7 @@ static PyObject* create_acoustic_material_from_parameters( PyObject*, PyObject* VAPY_REQUIRE_CONN_TRY; static char* pKeyWordList[] = { "parameters", "name", NULL }; - const char* pcFormat = "O!|s:create_acoustic_material_from_parameters"; + const char* pcFormat = "O|s:create_acoustic_material_from_parameters"; PyObject* pParams = nullptr; char* pcName = nullptr; if( !PyArg_ParseTupleAndKeywords( pArgs, pKeywordTuple, pcFormat, pKeyWordList, &pParams, &pcName ) ) @@ -2100,7 +2090,7 @@ static PyObject* create_acoustic_material( PyObject*, PyObject* pArgs, PyObject* VAPY_REQUIRE_CONN_TRY; static char* pKeyWordList[] = { "material", "name", NULL }; - const char* pcFormat = "O!|s:create_acoustic_material"; + const char* pcFormat = "O|s:create_acoustic_material"; PyObject* pMaterial = nullptr; char* pcName = nullptr; if( !PyArg_ParseTupleAndKeywords( pArgs, pKeywordTuple, pcFormat, pKeyWordList, &pMaterial, &pcName ) ) @@ -2168,7 +2158,7 @@ static PyObject* set_rendering_module_gain( PyObject*, PyObject* pArgs, PyObject std::string sID = pcID ? std::string( pcID ) : ""; g_pVANetClient->GetCoreInstance( )->SetRenderingModuleGain( sID, dGain ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -2211,7 +2201,7 @@ static PyObject* set_rendering_module_auralization_mode( PyObject*, PyObject* pA const int iAM = IVAInterface::ParseAuralizationModeStr( sAM, iCurrentAM ); g_pVANetClient->GetCoreInstance( )->SetRenderingModuleAuralizationMode( sID, iAM ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -2221,7 +2211,7 @@ static PyObject* get_rendering_module_parameters( PyObject*, PyObject* pArgs, Py VAPY_REQUIRE_CONN_TRY; static char* pKeyWordList[] = { "renderer_id", "arguments", NULL }; - const char* pcFormat = "s|O!:get_rendering_module_parameters"; + const char* pcFormat = "s|O:get_rendering_module_parameters"; char* pcID = nullptr; PyObject* pArguments = nullptr; if( !PyArg_ParseTupleAndKeywords( pArgs, pKeywordTuple, pcFormat, pKeyWordList, &pcID, &PyDict_Type, &pArguments ) ) @@ -2241,7 +2231,7 @@ static PyObject* set_rendering_module_parameters( PyObject*, PyObject* pArgs, Py VAPY_REQUIRE_CONN_TRY; static char* pKeyWordList[] = { "id", "parameters", NULL }; - const char* pcFormat = "sO!:set_rendering_module_parameters"; + const char* pcFormat = "sO:set_rendering_module_parameters"; char* pcID = nullptr; PyObject* pParams = NULL; if( !PyArg_ParseTupleAndKeywords( pArgs, pKeywordTuple, pcFormat, pKeyWordList, &pcID, &PyDict_Type, &pParams ) ) @@ -2250,7 +2240,7 @@ static PyObject* set_rendering_module_parameters( PyObject*, PyObject* pArgs, Py std::string sID = pcID ? std::string( pcID ) : ""; const CVAStruct oParameters = ConvertPythonDictToVAStruct( pParams ); g_pVANetClient->GetCoreInstance( )->SetRenderingModuleParameters( sID, oParameters ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -2269,7 +2259,7 @@ static PyObject* set_rendering_module_muted( PyObject*, PyObject* pArgs, PyObjec std::string sID = pcID ? std::string( pcID ) : ""; g_pVANetClient->GetCoreInstance( )->SetRenderingModuleMuted( sID, bMuted ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -2341,7 +2331,7 @@ static PyObject* set_reproduction_module_gain( PyObject*, PyObject* pArgs, PyObj std::string sID = pcID ? std::string( pcID ) : ""; g_pVANetClient->GetCoreInstance( )->SetReproductionModuleGain( sID, dGain ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -2351,7 +2341,7 @@ static PyObject* get_reproduction_module_parameters( PyObject*, PyObject* pArgs, VAPY_REQUIRE_CONN_TRY; static char* pKeyWordList[] = { "id", "arguments", NULL }; - const char* pcFormat = "s|O!:get_reproduction_module_parameters"; + const char* pcFormat = "s|O:get_reproduction_module_parameters"; char* pcID = nullptr; PyObject* pArguments = NULL; if( !PyArg_ParseTupleAndKeywords( pArgs, pKeywordTuple, pcFormat, pKeyWordList, &pcID, &PyDict_Type, &pArguments ) ) @@ -2371,7 +2361,7 @@ static PyObject* set_reproduction_module_parameters( PyObject*, PyObject* pArgs, VAPY_REQUIRE_CONN_TRY; static char* pKeyWordList[] = { "id", "parameters", NULL }; - const char* pcFormat = "sO!:set_reproduction_module_parameters"; + const char* pcFormat = "sO:set_reproduction_module_parameters"; char* pcID = nullptr; PyObject* pParams = NULL; if( !PyArg_ParseTupleAndKeywords( pArgs, pKeywordTuple, pcFormat, pKeyWordList, &pcID, &PyDict_Type, &pParams ) ) @@ -2380,7 +2370,7 @@ static PyObject* set_reproduction_module_parameters( PyObject*, PyObject* pArgs, std::string sID = pcID ? std::string( pcID ) : ""; const CVAStruct oParameters = ConvertPythonDictToVAStruct( pParams ); g_pVANetClient->GetCoreInstance( )->SetReproductionModuleParameters( sID, oParameters ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -2398,7 +2388,7 @@ static PyObject* set_reproduction_module_muted( PyObject*, PyObject* pArgs, PyOb std::string sID = pcID ? std::string( pcID ) : ""; g_pVANetClient->GetCoreInstance( )->SetReproductionModuleMuted( sID, bMuted ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -2437,7 +2427,7 @@ static PyObject* set_input_gain( PyObject*, PyObject* pArgs, PyObject* pKeywordT return NULL; g_pVANetClient->GetCoreInstance( )->SetInputGain( dGain ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -2453,7 +2443,7 @@ static PyObject* set_input_muted( PyObject*, PyObject* pArgs, PyObject* pKeyword return NULL; g_pVANetClient->GetCoreInstance( )->SetInputMuted( bMuted ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -2483,7 +2473,7 @@ static PyObject* set_output_gain( PyObject*, PyObject* pArgs, PyObject* pKeyword return NULL; g_pVANetClient->GetCoreInstance( )->SetOutputGain( dGain ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -2499,7 +2489,7 @@ static PyObject* set_output_muted( PyObject*, PyObject* pArgs, PyObject* pKeywor return NULL; g_pVANetClient->GetCoreInstance( )->SetOutputMuted( bMuted ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -2545,7 +2535,7 @@ static PyObject* set_global_auralization_mode( PyObject*, PyObject* pArgs, PyObj const int iAM = IVAInterface::ParseAuralizationModeStr( sAM, iCurrentAM ); g_pVANetClient->GetCoreInstance( )->SetGlobalAuralizationMode( iAM ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -2568,7 +2558,7 @@ static PyObject* set_core_clock( PyObject*, PyObject* pArgs, PyObject* pKeywordT return NULL; g_pVANetClient->GetCoreInstance( )->SetCoreClock( dTime ); - return Py_None; + Py_RETURN_NONE; VAPY_CATCH_RETURN; }; @@ -2778,3 +2768,5 @@ static PyObject* get_playback_action_str( PyObject*, PyObject* pArgs, PyObject* VAPY_CATCH_RETURN; }; + +#endif \ No newline at end of file diff --git a/tests/va_test_connection.py b/tests/va_test_connection.py index a388e519f81d6d2dd14b1405eb99343179cc9ffb..7f968995297de7f6042927aa0f55a0715842fbb8 100644 --- a/tests/va_test_connection.py +++ b/tests/va_test_connection.py @@ -5,7 +5,7 @@ import sys sys.path.append( '../Lib/site-packages' ) # deploy structure -import va +import VAPython as va print( "Testing va extension connection methods." )