diff --git a/.travis.yml b/.travis.yml index 1948ce24..441ce902 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ # # Required to run on platform / side: [UNIX] # -# Copyright (C) 2017 Sebastian M. Ernst +# Copyright (C) 2017-2019 Sebastian M. Ernst # # # The contents of this file are subject to the GNU Lesser General Public License @@ -27,8 +27,21 @@ # A virtual machine is required to run wine - is it? sudo: enabled +# Repository language +language: python + # A 'recent' version of Ubuntu for a recent version of Wine is required -dist: trusty +# Python 3.4 appears to not being offered for xenial at the moment +matrix: + include: + - dist: trusty + python: "3.4" + - dist: xenial + python: "3.5" + - dist: xenial + python: "3.6" + - dist: xenial + python: "3.7" # Get wine and mingw cross compiler # http://ubuntuhandbook.org/index.php/2017/01/install-wine-2-0-ubuntu-16-04-14-04-16-10/ @@ -38,6 +51,8 @@ before_install: - sudo dpkg --add-architecture i386 - wget https://dl.winehq.org/wine-builds/Release.key - sudo apt-key add Release.key + - wget https://dl.winehq.org/wine-builds/winehq.key + - sudo apt-key add winehq.key - sudo apt-add-repository 'https://dl.winehq.org/wine-builds/ubuntu/' - sudo apt-get -qq update - sudo apt-get install -y wine-staging @@ -50,15 +65,6 @@ before_install: - uname -a - lsb_release -a -# Repository language -language: python - -# Python version -python: - - "3.4" - - "3.5" - - "3.6" - # command to install dependencies and module install: - make dll diff --git a/CHANGES.rst b/CHANGES.rst index cd83a243..93869e9a 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,6 +1,16 @@ Changes ======= +0.0.12 (2019-02-02) +------------------- + +* FEATURE: Added official support for CPython 3.7. +* FEATURE: Added official support for Wine 4. +* FIX: Build folder was not automatically cleaned up before wheels were build, therefore they sometimes contained obsolete files & code. +* FIX: Travis configuration was missing new Wine repository key, which was breaking builds. +* Lots of fixes in documentation. +* New test script for easier development of new tests and features. + 0.0.11 (2018-04-10) ------------------- diff --git a/README.rst b/README.rst index a9c93d94..f4cbb508 100644 --- a/README.rst +++ b/README.rst @@ -72,8 +72,8 @@ Prerequisites ============= +--------------------+-------------------------------------------------------------------------------------------------------------+ -| for usage + - `CPython`_ 3.x (tested with 3.{4,5,6}) - no additional Python packages required + -| + - `Wine`_ 2.x/3.x (tested with 2.{5 to 21} regular & `staging`_) - expected to be in the user's `PATH`_ + +| for usage + - `CPython`_ 3.x (tested with 3.{4,5,6,7}) - no additional Python packages required + +| + - `Wine`_ 2.x/3.x/4.x (tested with regular & `staging`_) - expected to be in the user's `PATH`_ + +--------------------+-------------------------------------------------------------------------------------------------------------+ | for tests + - `pytest`_ + | + - `mingw cross-compiler`_ - for building DLLs against which examples and tests can be run + @@ -103,7 +103,7 @@ Installation Examples ======== -Start an interactive Python session under Unix and try the following: +Start an interactive Python session on your favorite Unix(-like) operating system and try the following: .. code:: python diff --git a/demo_dll/demo_dll.c b/demo_dll/demo_dll.c index 0d37c518..ea329d57 100644 --- a/demo_dll/demo_dll.c +++ b/demo_dll/demo_dll.c @@ -8,7 +8,7 @@ Calling routines in Windows DLLs from Python scripts running on unixlike systems Required to run on platform / side: [WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License @@ -449,6 +449,21 @@ void __stdcall DEMODLL replace_letter_in_null_terminated_string_unicode_b( } +void __stdcall DEMODLL replace_letter_in_null_terminated_string_r( + char **in_string, + char old_letter, + char new_letter + ) +{ + int i; + for (i = 0; i < strlen((*in_string)); i++) { + if((*in_string)[i] == old_letter) { + (*in_string)[i] = new_letter; + } + } +} + + void __stdcall DEMODLL tag_string_a( char *in_string, void *out_string diff --git a/demo_dll/demo_dll.h b/demo_dll/demo_dll.h index 3338ab44..b768a485 100644 --- a/demo_dll/demo_dll.h +++ b/demo_dll/demo_dll.h @@ -8,7 +8,7 @@ Calling routines in Windows DLLs from Python scripts running on unixlike systems Required to run on platform / side: [WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License @@ -204,6 +204,12 @@ void __stdcall DEMODLL replace_letter_in_null_terminated_string_b( char new_letter ); +void __stdcall DEMODLL replace_letter_in_null_terminated_string_r( + char **in_string, + char old_letter, + char new_letter + ); + void __stdcall DEMODLL replace_letter_in_null_terminated_string_unicode_a( wchar_t *in_string, wchar_t old_letter, diff --git a/demo_dll/makefile b/demo_dll/makefile index 3d816fc9..a36722c3 100644 --- a/demo_dll/makefile +++ b/demo_dll/makefile @@ -6,7 +6,7 @@ # # Required to run on platform / side: [UNIX] # -# Copyright (C) 2017-2018 Sebastian M. Ernst +# Copyright (C) 2017-2019 Sebastian M. Ernst # # # The contents of this file are subject to the GNU Lesser General Public License diff --git a/docs/Makefile b/docs/Makefile index bb361a35..31afca6b 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -6,7 +6,7 @@ # # Required to run on platform / side: [UNIX] # -# Copyright (C) 2017-2018 Sebastian M. Ernst +# Copyright (C) 2017-2019 Sebastian M. Ernst # # # The contents of this file are subject to the GNU Lesser General Public License diff --git a/docs/conf.py b/docs/conf.py index 852cbcf6..40805f20 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -11,7 +11,7 @@ Required to run on platform / side: [UNIX] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/docs/memsync.rst b/docs/memsync.rst index 032fcf6a..4f4d2632 100644 --- a/docs/memsync.rst +++ b/docs/memsync.rst @@ -172,7 +172,7 @@ definitions like the following: ); The ``image_data`` parameter is a flattened 1D array representing a 2D image. -Its length is defined by its width and its height. So the length of array equals +Its length is defined by its width and its height. So the length of the array equals ``image_width * image_height``. For cases like this, ``memsync`` has the ability to dynamically compute the length of the memory through custom functions. Let's have a look at how the above function would be configured in *Python*: @@ -196,7 +196,7 @@ specified lambda function. Using string buffers, null-terminated strings and Unicode --------------------------------------------------------- -Let's assume you are confronted with a regular Python (3) string. With the help of a +Let's assume you are confronted with a regular *Python* (3) string. With the help of a DLL function, you want to replace all occurrences of a letter with another letter. .. code:: python @@ -213,7 +213,7 @@ The DLL function's definition looks like this: char new_letter ); -In Python, it can be configured as follows: +In *Python*, it can be configured as follows: .. code:: python @@ -232,8 +232,8 @@ In Python, it can be configured as follows: The above configuration indicates that the first argument of the function is a pointer to a NULL-terminated string. -While Python (3) strings are actually Unicode strings, the function accepts an -array of type ``char`` - a bytes array in Python terms. I.e. you have to encode the +While *Python* (3) strings are actually Unicode strings, the function accepts an +array of type ``char`` - a bytes array in *Python* terms. I.e. you have to encode the string before it is copied into a string buffer. The following example illustrates how the function ``replace_letter`` can be called on the string ``some_string``, exchanging all letters ``a`` with ``e``. Subsequently, the result is printed. @@ -323,7 +323,7 @@ to change the contents of the ``memsync`` attribute of the function prototype, The above syntax also does not interfere with ``ctypes`` on *Windows*, i.e. the code remains perfectly platform-independent. Once the function prototype -has been configured though ``memsync``, it can be applied to a *Python* function: +has been configured through ``memsync``, it can be applied to a *Python* function: .. code:: python @@ -401,7 +401,7 @@ of multiple (or even zero) path lists, if the optional ``f`` key (custom length Key: ``n``, NULL-terminated string flag (optional) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Can be set to ``True`` is a NULL-terminated string is passed as an argument. +Can be set to ``True`` if a NULL-terminated string is passed as an argument. ``memsync`` will automatically determine the length of the string, so no extra information on its length (through ``l`` is required). @@ -419,7 +419,7 @@ Key: ``t``, data type of pointer (PyCSimpleType or PyCStructType) (optional) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This field expects a string representing the name of a ctypes datatype. -If you want to specify a custom structure type, you simple specify its class name as a string instead. +If you want to specify a custom structure type, you simply specify its class name as a string instead. This parameter will be used by ``ctypes.sizeof`` for determining the datatype's size in bytes. The result is then multiplied with the ``length`` to get an actual size of the diff --git a/examples/demo_call_win.py b/examples/demo_call_win.py index 6baf27e3..9b6c2328 100755 --- a/examples/demo_call_win.py +++ b/examples/demo_call_win.py @@ -11,7 +11,7 @@ Required to run on platform / side: [WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/examples/test_callback.py b/examples/test_callback.py index c83156a8..f5cd2c41 100755 --- a/examples/test_callback.py +++ b/examples/test_callback.py @@ -11,7 +11,7 @@ Required to run on platform / side: [UNIX, WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/examples/test_cookbook.py b/examples/test_cookbook.py index 85bf4f59..81b7ad2a 100755 --- a/examples/test_cookbook.py +++ b/examples/test_cookbook.py @@ -11,7 +11,7 @@ Required to run on platform / side: [UNIX, WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/examples/test_zugbruecke.py b/examples/test_zugbruecke.py index 44babc73..1891ab30 100755 --- a/examples/test_zugbruecke.py +++ b/examples/test_zugbruecke.py @@ -11,7 +11,7 @@ Required to run on platform / side: [UNIX, WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/examples/test_zugbruecke_perf.py b/examples/test_zugbruecke_perf.py index 50278855..59c0acd8 100755 --- a/examples/test_zugbruecke_perf.py +++ b/examples/test_zugbruecke_perf.py @@ -11,7 +11,7 @@ Required to run on platform / side: [UNIX, WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/makefile b/makefile index 642563e4..bdd5a282 100644 --- a/makefile +++ b/makefile @@ -6,7 +6,7 @@ # # Required to run on platform / side: [UNIX] # -# Copyright (C) 2017-2018 Sebastian M. Ernst +# Copyright (C) 2017-2019 Sebastian M. Ernst # # # The contents of this file are subject to the GNU Lesser General Public License @@ -28,6 +28,7 @@ docu: @(cd docs; make clean; make html) release: + -rm build/* -rm dist/* -rm -r src/*.egg-info python setup.py sdist bdist_wheel diff --git a/run_test.py b/run_test.py new file mode 100644 index 00000000..e92b43d0 --- /dev/null +++ b/run_test.py @@ -0,0 +1,120 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +""" + +ZUGBRUECKE +Calling routines in Windows DLLs from Python scripts running on unixlike systems +https://github.com/pleiszenburg/zugbruecke + + run_test.py: Run one individual test + + Required to run on platform / side: [UNIX, WINE] + + Copyright (C) 2017-2019 Sebastian M. Ernst + + +The contents of this file are subject to the GNU Lesser General Public License +Version 2.1 ("LGPL" or "License"). You may not use this file except in +compliance with the License. You may obtain a copy of the License at +https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt +https://github.com/pleiszenburg/zugbruecke/blob/master/LICENSE + +Software distributed under the License is distributed on an "AS IS" basis, +WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the +specific language governing rights and limitations under the License. + + +""" + + +# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +# IMPORT +# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +import argparse +import importlib +import os +import sys +import traceback + + +# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +# CONST +# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +ZB_CONFIG_FN = '.zugbruecke.json' + + +# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +# CLASSES AND ROUTINES +# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +def run_test(test_module, test_routine): + + cwd = os.path.dirname(os.path.abspath(__file__)) + + test_fld = None + with open('setup.cfg', 'r') as f: + for line in f: + if not 'testpaths = ' in line: + continue + test_fld = line.split(' = ', 1)[1].strip() + break + if test_fld is None: + raise # TODO + if not os.path.isdir(os.path.join(cwd, test_fld)): + raise # TODO + + sys.path.append(os.path.join(cwd, test_fld)) + + getattr(importlib.import_module(test_module), test_routine)() + + +def overwrite_configuration(): + + if os.path.isfile(ZB_CONFIG_FN): + with open(ZB_CONFIG_FN, 'r') as f: + old_config = f.read() + else: + old_config = None + + with open(ZB_CONFIG_FN, 'w') as f: + f.write('{"log_level": 10}\n') + + return old_config + + +def restore_configuration(old_config): + + if old_config is None: + os.remove(ZB_CONFIG_FN) + return + + with open(ZB_CONFIG_FN, 'w') as f: + f.write(old_config) + + +# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +# INIT +# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +if __name__ == '__main__': + + parser = argparse.ArgumentParser() + parser.add_argument( + '-m', '--module', type = str, nargs = 1 + ) + parser.add_argument( + '-r', '--routine', type = str, nargs = 1 + ) + args = parser.parse_args() + + old_config = overwrite_configuration() + + try: + run_test(args.module[0], args.routine[0]) + except: + traceback.print_exc() + + restore_configuration(old_config) diff --git a/scripts/wine-pip b/scripts/wine-pip index 984cff1f..426ea843 100755 --- a/scripts/wine-pip +++ b/scripts/wine-pip @@ -8,7 +8,7 @@ # # Required to run on platform / side: [UNIX] # -# Copyright (C) 2017-2018 Sebastian M. Ernst +# Copyright (C) 2017-2019 Sebastian M. Ernst # # # The contents of this file are subject to the GNU Lesser General Public License diff --git a/scripts/wine-pytest b/scripts/wine-pytest index e0ae28f9..ce224898 100644 --- a/scripts/wine-pytest +++ b/scripts/wine-pytest @@ -8,7 +8,7 @@ # # Required to run on platform / side: [UNIX] # -# Copyright (C) 2017-2018 Sebastian M. Ernst +# Copyright (C) 2017-2019 Sebastian M. Ernst # # # The contents of this file are subject to the GNU Lesser General Public License diff --git a/scripts/wine-python b/scripts/wine-python index 3099f91e..2c968f16 100755 --- a/scripts/wine-python +++ b/scripts/wine-python @@ -8,7 +8,7 @@ # # Required to run on platform / side: [UNIX] # -# Copyright (C) 2017-2018 Sebastian M. Ernst +# Copyright (C) 2017-2019 Sebastian M. Ernst # # # The contents of this file are subject to the GNU Lesser General Public License diff --git a/setup.py b/setup.py index b3409779..1baa0e38 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License @@ -46,13 +46,13 @@ # Bump version HERE! -_version_ = '0.0.11' +_version_ = '0.0.12' # List all versions of Python which are supported confirmed_python_versions = [ ('Programming Language :: Python :: %s' % x) - for x in '3.4 3.5 3.6'.split() + for x in '3.4 3.5 3.6 3.7'.split() ] diff --git a/src/zugbruecke/__init__.py b/src/zugbruecke/__init__.py index 4f7f726f..5e6189c8 100644 --- a/src/zugbruecke/__init__.py +++ b/src/zugbruecke/__init__.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/src/zugbruecke/_server_.py b/src/zugbruecke/_server_.py index c3afd4d9..aa7e701c 100755 --- a/src/zugbruecke/_server_.py +++ b/src/zugbruecke/_server_.py @@ -11,7 +11,7 @@ Required to run on platform / side: [WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/src/zugbruecke/_wrapper_.py b/src/zugbruecke/_wrapper_.py index c8696843..87813e28 100644 --- a/src/zugbruecke/_wrapper_.py +++ b/src/zugbruecke/_wrapper_.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/src/zugbruecke/core/__init__.py b/src/zugbruecke/core/__init__.py index 60bafced..54f2ffeb 100644 --- a/src/zugbruecke/core/__init__.py +++ b/src/zugbruecke/core/__init__.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX, WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/src/zugbruecke/core/callback_client.py b/src/zugbruecke/core/callback_client.py index d253622c..83787397 100644 --- a/src/zugbruecke/core/callback_client.py +++ b/src/zugbruecke/core/callback_client.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX, WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/src/zugbruecke/core/callback_server.py b/src/zugbruecke/core/callback_server.py index bc934129..5f54a0c6 100644 --- a/src/zugbruecke/core/callback_server.py +++ b/src/zugbruecke/core/callback_server.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX, WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/src/zugbruecke/core/config.py b/src/zugbruecke/core/config.py index ac6b5fff..e3c5f3b6 100644 --- a/src/zugbruecke/core/config.py +++ b/src/zugbruecke/core/config.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License @@ -127,7 +127,7 @@ def __locate_and_read_config_files__(): # Look for config in the usual spots for file_location in [ - os.curdir, + os.getcwd(), # os.curdir os.environ.get('ZUGBRUECKE'), __get_default_config_directory__(), '/etc/zugbruecke' diff --git a/src/zugbruecke/core/const.py b/src/zugbruecke/core/const.py index 577ba705..672cd6bc 100644 --- a/src/zugbruecke/core/const.py +++ b/src/zugbruecke/core/const.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX, WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/src/zugbruecke/core/data/__init__.py b/src/zugbruecke/core/data/__init__.py index 60e3523b..779db58a 100644 --- a/src/zugbruecke/core/data/__init__.py +++ b/src/zugbruecke/core/data/__init__.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX, WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/src/zugbruecke/core/data/arg_contents.py b/src/zugbruecke/core/data/arg_contents.py index 4403d248..b68b334e 100644 --- a/src/zugbruecke/core/data/arg_contents.py +++ b/src/zugbruecke/core/data/arg_contents.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX, WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/src/zugbruecke/core/data/arg_definition.py b/src/zugbruecke/core/data/arg_definition.py index 5643c854..5d00c2f8 100644 --- a/src/zugbruecke/core/data/arg_definition.py +++ b/src/zugbruecke/core/data/arg_definition.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX, WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/src/zugbruecke/core/data/mem_contents.py b/src/zugbruecke/core/data/mem_contents.py index f3831290..472fbba9 100644 --- a/src/zugbruecke/core/data/mem_contents.py +++ b/src/zugbruecke/core/data/mem_contents.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX, WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/src/zugbruecke/core/data/mem_definition.py b/src/zugbruecke/core/data/mem_definition.py index 25f933ab..cf379a65 100644 --- a/src/zugbruecke/core/data/mem_definition.py +++ b/src/zugbruecke/core/data/mem_definition.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX, WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/src/zugbruecke/core/data/memory.py b/src/zugbruecke/core/data/memory.py index d0ca29c0..c471accb 100644 --- a/src/zugbruecke/core/data/memory.py +++ b/src/zugbruecke/core/data/memory.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX, WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/src/zugbruecke/core/dll_client.py b/src/zugbruecke/core/dll_client.py index 5379b40d..d9814fd7 100644 --- a/src/zugbruecke/core/dll_client.py +++ b/src/zugbruecke/core/dll_client.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/src/zugbruecke/core/dll_server.py b/src/zugbruecke/core/dll_server.py index a8f0e176..44a517b2 100644 --- a/src/zugbruecke/core/dll_server.py +++ b/src/zugbruecke/core/dll_server.py @@ -10,7 +10,7 @@ Required to run on platform / side: [WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/src/zugbruecke/core/interpreter.py b/src/zugbruecke/core/interpreter.py index 3a29953c..d9a4db6b 100644 --- a/src/zugbruecke/core/interpreter.py +++ b/src/zugbruecke/core/interpreter.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/src/zugbruecke/core/lib.py b/src/zugbruecke/core/lib.py index 241fa319..471a4153 100644 --- a/src/zugbruecke/core/lib.py +++ b/src/zugbruecke/core/lib.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX, WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/src/zugbruecke/core/log.py b/src/zugbruecke/core/log.py index 7f96ab2a..1d475008 100644 --- a/src/zugbruecke/core/log.py +++ b/src/zugbruecke/core/log.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX, WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/src/zugbruecke/core/path.py b/src/zugbruecke/core/path.py index 90ae6ce8..4d044f42 100644 --- a/src/zugbruecke/core/path.py +++ b/src/zugbruecke/core/path.py @@ -10,7 +10,7 @@ Required to run on platform / side: [WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/src/zugbruecke/core/routine_client.py b/src/zugbruecke/core/routine_client.py index 23b3439d..e3010ad2 100644 --- a/src/zugbruecke/core/routine_client.py +++ b/src/zugbruecke/core/routine_client.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/src/zugbruecke/core/routine_server.py b/src/zugbruecke/core/routine_server.py index 45a55d79..6734f6a1 100644 --- a/src/zugbruecke/core/routine_server.py +++ b/src/zugbruecke/core/routine_server.py @@ -10,7 +10,7 @@ Required to run on platform / side: [WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/src/zugbruecke/core/rpc.py b/src/zugbruecke/core/rpc.py index 5bbdadef..eba80637 100644 --- a/src/zugbruecke/core/rpc.py +++ b/src/zugbruecke/core/rpc.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX, WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/src/zugbruecke/core/session_client.py b/src/zugbruecke/core/session_client.py index 6e290c78..b8937009 100644 --- a/src/zugbruecke/core/session_client.py +++ b/src/zugbruecke/core/session_client.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/src/zugbruecke/core/session_server.py b/src/zugbruecke/core/session_server.py index 72d5f753..80280ca0 100644 --- a/src/zugbruecke/core/session_server.py +++ b/src/zugbruecke/core/session_server.py @@ -10,7 +10,7 @@ Required to run on platform / side: [WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/src/zugbruecke/core/wineenv.py b/src/zugbruecke/core/wineenv.py index a8b4ee88..a7b0a474 100644 --- a/src/zugbruecke/core/wineenv.py +++ b/src/zugbruecke/core/wineenv.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/src/zugbruecke/util.py b/src/zugbruecke/util.py index b3f90233..02fc886d 100644 --- a/src/zugbruecke/util.py +++ b/src/zugbruecke/util.py @@ -14,7 +14,7 @@ https://github.com/python/cpython/blob/master/Lib/ctypes/util.py https://github.com/python/cpython/commit/a76f014278bd1643e93fdfa9e88f9414ce8354a6 - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/src/zugbruecke/wintypes.py b/src/zugbruecke/wintypes.py index 8db4271e..cf8a8f22 100644 --- a/src/zugbruecke/wintypes.py +++ b/src/zugbruecke/wintypes.py @@ -18,7 +18,7 @@ https://github.com/python/cpython/blob/3.6/LICENSE Modifications from original: - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/tests/test_apply_filter_to_image.py b/tests/test_apply_filter_to_image.py index f06ab45f..48d7aff0 100644 --- a/tests/test_apply_filter_to_image.py +++ b/tests/test_apply_filter_to_image.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX, WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/tests/test_avg.py b/tests/test_avg.py index 71b185ee..72d8cc35 100644 --- a/tests/test_avg.py +++ b/tests/test_avg.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX, WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/tests/test_bubblesort.py b/tests/test_bubblesort.py index 6fb9610c..ada3faed 100644 --- a/tests/test_bubblesort.py +++ b/tests/test_bubblesort.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX, WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/tests/test_bubblesort_segments.py b/tests/test_bubblesort_segments.py index b997cd53..46832dbf 100644 --- a/tests/test_bubblesort_segments.py +++ b/tests/test_bubblesort_segments.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX, WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/tests/test_bubblesort_struct.py b/tests/test_bubblesort_struct.py index 5de5732d..439bc9b7 100644 --- a/tests/test_bubblesort_struct.py +++ b/tests/test_bubblesort_struct.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX, WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/tests/test_callback_optional.py b/tests/test_callback_optional.py index b1f492c6..1d7220ba 100644 --- a/tests/test_callback_optional.py +++ b/tests/test_callback_optional.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX, WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/tests/test_callback_simple.py b/tests/test_callback_simple.py index 0a63fb27..3cb337b9 100644 --- a/tests/test_callback_simple.py +++ b/tests/test_callback_simple.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX, WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/tests/test_callback_simple_struct.py b/tests/test_callback_simple_struct.py index 1176de09..cf78fee1 100644 --- a/tests/test_callback_simple_struct.py +++ b/tests/test_callback_simple_struct.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX, WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/tests/test_devide.py b/tests/test_devide.py index a5606d7d..2bca9808 100644 --- a/tests/test_devide.py +++ b/tests/test_devide.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX, WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/tests/test_distance.py b/tests/test_distance.py index f43179a0..e617d0d1 100644 --- a/tests/test_distance.py +++ b/tests/test_distance.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX, WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/tests/test_error_argtypes.py b/tests/test_error_argtypes.py index 356ac810..9ae279c2 100644 --- a/tests/test_error_argtypes.py +++ b/tests/test_error_argtypes.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX, WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/tests/test_error_callargs.py b/tests/test_error_callargs.py index bd1a3432..bf3e137e 100644 --- a/tests/test_error_callargs.py +++ b/tests/test_error_callargs.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX, WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/tests/test_error_missingdll.py b/tests/test_error_missingdll.py index 614ba548..e51fbae4 100644 --- a/tests/test_error_missingdll.py +++ b/tests/test_error_missingdll.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX, WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/tests/test_error_missingroutine.py b/tests/test_error_missingroutine.py index ce7cf52e..51e24dfe 100644 --- a/tests/test_error_missingroutine.py +++ b/tests/test_error_missingroutine.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX, WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/tests/test_fibonacci_sequence.py b/tests/test_fibonacci_sequence.py index 1d1e6427..1e8bae68 100644 --- a/tests/test_fibonacci_sequence.py +++ b/tests/test_fibonacci_sequence.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX, WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/tests/test_gauss_elimination.py b/tests/test_gauss_elimination.py index 9bc44813..dbd286a9 100644 --- a/tests/test_gauss_elimination.py +++ b/tests/test_gauss_elimination.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX, WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/tests/test_gdc.py b/tests/test_gdc.py index 833be684..8724a803 100644 --- a/tests/test_gdc.py +++ b/tests/test_gdc.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX, WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/tests/test_get_const_int.py b/tests/test_get_const_int.py index ec06aef6..161e77c4 100644 --- a/tests/test_get_const_int.py +++ b/tests/test_get_const_int.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX, WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/tests/test_in_mantel.py b/tests/test_in_mantel.py index 5ba14894..285abd9d 100644 --- a/tests/test_in_mantel.py +++ b/tests/test_in_mantel.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX, WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/tests/test_mix_rgb_colors.py b/tests/test_mix_rgb_colors.py index d125040c..886be847 100644 --- a/tests/test_mix_rgb_colors.py +++ b/tests/test_mix_rgb_colors.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX, WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/tests/test_null_terminated_string.py b/tests/test_null_terminated_string.py index 7297690a..ad31ddfe 100644 --- a/tests/test_null_terminated_string.py +++ b/tests/test_null_terminated_string.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX, WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/tests/test_r_strsxp.py b/tests/test_r_strsxp.py new file mode 100644 index 00000000..3e3018ae --- /dev/null +++ b/tests/test_r_strsxp.py @@ -0,0 +1,93 @@ +# -*- coding: utf-8 -*- + +""" + +ZUGBRUECKE +Calling routines in Windows DLLs from Python scripts running on unixlike systems +https://github.com/pleiszenburg/zugbruecke + + tests/test_sqrt_int.py: Test function with single parameter + + Required to run on platform / side: [UNIX, WINE] + + Copyright (C) 2017-2019 Sebastian M. Ernst + + +The contents of this file are subject to the GNU Lesser General Public License +Version 2.1 ("LGPL" or "License"). You may not use this file except in +compliance with the License. You may obtain a copy of the License at +https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt +https://github.com/pleiszenburg/zugbruecke/blob/master/LICENSE + +Software distributed under the License is distributed on an "AS IS" basis, +WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the +specific language governing rights and limitations under the License. + + +""" + + +# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +# IMPORT +# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +from sys import platform +if any([platform.startswith(os_name) for os_name in ['linux', 'darwin', 'freebsd']]): + import zugbruecke as ctypes +elif platform.startswith('win'): + import ctypes + +import pytest + + +# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +# CLASSES AND ROUTINES +# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +class sample_class: + + + def __init__(self): + + self.__dll__ = ctypes.windll.LoadLibrary('tests/demo_dll.dll') + + self.__replace_r__ = self.__dll__.replace_letter_in_null_terminated_string_r + self.__replace_r__.argtypes = ( + ctypes.POINTER(ctypes.POINTER(ctypes.c_char)), # Generate pointer to char manually + ctypes.c_char, + ctypes.c_char + ) + self.__replace_r__.memsync = [ + { + 'p': [0, -1], + 'n': True + } + ] + + + def replace_r(self, in_string, old_letter, new_letter): + + string_buffer = (ctypes.c_char_p * 1)(in_string.encode('utf-8')) + string_buffer_p = ctypes.cast( + string_buffer, + ctypes.POINTER(ctypes.POINTER(ctypes.c_char)) + ) + + self.__replace_r__( + string_buffer_p, + old_letter.encode('utf-8'), + new_letter.encode('utf-8') + ) + + return string_buffer[:][0].decode('utf-8') + + +# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +# TEST(s) +# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +@pytest.mark.xfail(strict = False, reason = 'not yet implemented') +def test_r_strsxp(): + + sample = sample_class() + assert 'zetegehube' == sample.replace_r('zategahuba', 'a', 'e') diff --git a/tests/test_sqrt_int.py b/tests/test_sqrt_int.py index 09e245ef..2754e08d 100644 --- a/tests/test_sqrt_int.py +++ b/tests/test_sqrt_int.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX, WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/tests/test_square_int_array.py b/tests/test_square_int_array.py index e8c5bd25..5b5c489e 100644 --- a/tests/test_square_int_array.py +++ b/tests/test_square_int_array.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX, WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/tests/test_square_int_array_with_struct.py b/tests/test_square_int_array_with_struct.py index 53d210ec..938de768 100644 --- a/tests/test_square_int_array_with_struct.py +++ b/tests/test_square_int_array_with_struct.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX, WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/tests/test_tag_string.py b/tests/test_tag_string.py index 47333836..99fd7a53 100644 --- a/tests/test_tag_string.py +++ b/tests/test_tag_string.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX, WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License diff --git a/tests/test_vector3d_add.py b/tests/test_vector3d_add.py index b825d79b..65ff2e3d 100644 --- a/tests/test_vector3d_add.py +++ b/tests/test_vector3d_add.py @@ -10,7 +10,7 @@ Required to run on platform / side: [UNIX, WINE] - Copyright (C) 2017-2018 Sebastian M. Ernst + Copyright (C) 2017-2019 Sebastian M. Ernst The contents of this file are subject to the GNU Lesser General Public License