Skip to content

Commit

Permalink
0.0.8 release
Browse files Browse the repository at this point in the history
  • Loading branch information
s-m-e committed Mar 18, 2018
2 parents 20f2e44 + 81bcd8d commit 32db77f
Show file tree
Hide file tree
Showing 56 changed files with 1,215 additions and 121 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ htmlcov/
.coverage
.coverage.*
.cache
.pytest_cache/
nosetests.xml
coverage.xml
*,cover
Expand Down
15 changes: 11 additions & 4 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Changes
=======

0.0.8 (2018-03-18)
------------------

* FEATURE: Support for structures and pointers as return values, see issue #14.
* FEATURE: (Limited) support for call back functions (function pointers) as DLL argument types, see issues #3 and #4.
* FIX: ``argtypes`` definitions (with one single argument) were not raising a ``TypeError`` like ``ctypes`` does if not passed as a tuple or list, see issue #21.

0.0.7 (2018-03-05)
------------------

Expand All @@ -20,24 +27,24 @@ Changes
0.0.5 (2017-11-13)
------------------

* Added support for light-weight pointers (``ctypes.byref``)
* FEATURE: Support for light-weight pointers (``ctypes.byref``)
* FIX: Elements within structures are properly synchronized even if they are not a pointer on their own.
* FIX: Structure objects in arrays of structures are properly initialized.
* FIX: Links in ``README.rst`` work when rendered on PyPI.

0.0.4 (2017-11-05)
------------------

* Implemented full support for multidimensional fixed length arrays
* FEATURE: Full support for multidimensional fixed length arrays

0.0.3 (2017-11-02)
------------------

* Implemented fixed length 1D arrays
* FEATURE: Fixed length 1D arrays
* Refactored argument packing and unpacking code
* Plenty of cleanups based on static code analysis
* Introduced ``Python``'s ``any`` functions in a number of places
* Fixed lots of typos and grammar issues in documentation
* FIX: Lots of typos and grammar issues in documentation

0.0.2 (2017-07-28)
------------------
Expand Down
68 changes: 67 additions & 1 deletion demo_dll/demo_dll.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 Sebastian M. Ernst <[email protected]>
Copyright (C) 2017-2018 Sebastian M. Ernst <[email protected]>
<LICENSE_BLOCK>
The contents of this file are subject to the GNU Lesser General Public License
Expand Down Expand Up @@ -112,6 +112,18 @@ double __stdcall DEMODLL cookbook_distance(
}


/* Function involving a C data structure - returning a pointer to a variable */
double __stdcall DEMODLL *cookbook_distance_pointer(
cookbook_point *p1,
cookbook_point *p2
)
{
double *distance_p = (double *)malloc(sizeof(double));
*distance_p = hypot(p1->x - p2->x, p1->y - p2->y);
return distance_p;
}


// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// zugbruecke demo
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Expand Down Expand Up @@ -187,6 +199,37 @@ void __stdcall DEMODLL gauss_elimination(
}


vector3d __stdcall DEMODLL *vector3d_add(
vector3d *v1,
vector3d *v2
)
{

vector3d *v3 = malloc(sizeof(vector3d));

v3->x = v1->x + v2->x;
v3->y = v1->y + v2->y;
v3->z = v1->z + v2->z;

return v3;

}


int16_t __stdcall DEMODLL sqrt_int(
int16_t a
)
{
return a * a;
}


int16_t __stdcall DEMODLL get_const_int(void)
{
return sqrt(49);
}


float __stdcall DEMODLL simple_demo_routine(
float param_a,
float param_b
Expand Down Expand Up @@ -221,6 +264,29 @@ void __stdcall DEMODLL complex_demo_routine(
}


// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// zugbruecke demo: callback
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

int16_t __stdcall DEMODLL sum_elements_from_callback(
int16_t len,
conveyor_belt get_data
)
{

int16_t sum = 0;
int16_t i;

for(i = 0; i < len; i++)
{
sum += get_data(i);
}

return sum;

}


// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// DLL infrastructure
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Expand Down
33 changes: 32 additions & 1 deletion demo_dll/demo_dll.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 Sebastian M. Ernst <[email protected]>
Copyright (C) 2017-2018 Sebastian M. Ernst <[email protected]>
<LICENSE_BLOCK>
The contents of this file are subject to the GNU Lesser General Public License
Expand Down Expand Up @@ -88,6 +88,10 @@ double __stdcall DEMODLL cookbook_distance(
cookbook_point *p2
);

double __stdcall DEMODLL *cookbook_distance_pointer(
cookbook_point *p1,
cookbook_point *p2
);

// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// zugbruecke demo
Expand All @@ -109,6 +113,21 @@ void __stdcall DEMODLL gauss_elimination(
float (*x)[3]
);

typedef struct vector3d {
int16_t x, y, z;
} vector3d;

vector3d __stdcall DEMODLL *vector3d_add(
vector3d *p1,
vector3d *p2
);

int16_t __stdcall DEMODLL sqrt_int(
int16_t a
);

int16_t __stdcall DEMODLL get_const_int(void);

struct test
{
char el_char;
Expand All @@ -132,6 +151,18 @@ void __stdcall DEMODLL complex_demo_routine(
);


// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// zugbruecke demo: callback
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

typedef int16_t __stdcall (*conveyor_belt)(int16_t index);

int16_t __stdcall DEMODLL sum_elements_from_callback(
int16_t len,
conveyor_belt get_data
);


// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// DLL infrastructure
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Expand Down
2 changes: 1 addition & 1 deletion demo_dll/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
# Required to run on platform / side: [UNIX]
#
# Copyright (C) 2017 Sebastian M. Ernst <[email protected]>
# Copyright (C) 2017-2018 Sebastian M. Ernst <[email protected]>
#
# <LICENSE_BLOCK>
# The contents of this file are subject to the GNU Lesser General Public License
Expand Down
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
# Required to run on platform / side: [UNIX]
#
# Copyright (C) 2017 Sebastian M. Ernst <[email protected]>
# Copyright (C) 2017-2018 Sebastian M. Ernst <[email protected]>
#
# <LICENSE_BLOCK>
# The contents of this file are subject to the GNU Lesser General Public License
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Required to run on platform / side: [UNIX]
Copyright (C) 2017 Sebastian M. Ernst <[email protected]>
Copyright (C) 2017-2018 Sebastian M. Ernst <[email protected]>
<LICENSE_BLOCK>
The contents of this file are subject to the GNU Lesser General Public License
Expand Down Expand Up @@ -77,7 +77,7 @@ def fetch_version_string():

# General information about the project.
project = 'zugbruecke'
copyright = '2017 Sebastian M. Ernst'
copyright = '2017-2018 Sebastian M. Ernst'
author = 'Sebastian M. Ernst'

# The version info for the project you're documenting, acts as replacement for
Expand Down
2 changes: 1 addition & 1 deletion examples/demo_call_win.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Required to run on platform / side: [WINE]
Copyright (C) 2017 Sebastian M. Ernst <[email protected]>
Copyright (C) 2017-2018 Sebastian M. Ernst <[email protected]>
<LICENSE_BLOCK>
The contents of this file are subject to the GNU Lesser General Public License
Expand Down
75 changes: 75 additions & 0 deletions examples/test_callback.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
ZUGBRUECKE
Calling routines in Windows DLLs from Python scripts running on unixlike systems
https://github.com/pleiszenburg/zugbruecke
examples/test_callback.py: Demonstrates callback routines as arguments
Required to run on platform / side: [UNIX, WINE]
Copyright (C) 2017-2018 Sebastian M. Ernst <[email protected]>
<LICENSE_BLOCK>
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.
</LICENSE_BLOCK>
"""


# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# IMPORT
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

from sys import platform

if any([platform.startswith(os_name) for os_name in ['linux', 'darwin', 'freebsd']]):

f = open('.zugbruecke.json', 'w')
f.write('{"log_level": 10}')
f.close()

import zugbruecke as ctypes

elif platform.startswith('win'):

import ctypes

else:

raise # TODO unsupported platform


# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# RUN
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

if __name__ == '__main__':

DATA = [1, 6, 8, 4, 9, 7, 4, 2, 5, 2]

conveyor_belt = ctypes.WINFUNCTYPE(ctypes.c_int16, ctypes.c_int16)

@conveyor_belt
def get_data(index):
print((index, DATA[index]))
return DATA[index]

dll = ctypes.windll.LoadLibrary('demo_dll.dll')
sum_elements_from_callback = dll.sum_elements_from_callback
sum_elements_from_callback.argtypes = (ctypes.c_int16, conveyor_belt)
sum_elements_from_callback.restype = ctypes.c_int16

test_sum = sum_elements_from_callback(len(DATA), get_data)
print(('sum', 48, test_sum))
2 changes: 1 addition & 1 deletion examples/test_cookbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Required to run on platform / side: [UNIX, WINE]
Copyright (C) 2017 Sebastian M. Ernst <[email protected]>
Copyright (C) 2017-2018 Sebastian M. Ernst <[email protected]>
<LICENSE_BLOCK>
The contents of this file are subject to the GNU Lesser General Public License
Expand Down
2 changes: 1 addition & 1 deletion examples/test_zugbruecke.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Required to run on platform / side: [UNIX, WINE]
Copyright (C) 2017 Sebastian M. Ernst <[email protected]>
Copyright (C) 2017-2018 Sebastian M. Ernst <[email protected]>
<LICENSE_BLOCK>
The contents of this file are subject to the GNU Lesser General Public License
Expand Down
2 changes: 1 addition & 1 deletion examples/test_zugbruecke_perf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Required to run on platform / side: [UNIX, WINE]
Copyright (C) 2017 Sebastian M. Ernst <[email protected]>
Copyright (C) 2017-2018 Sebastian M. Ernst <[email protected]>
<LICENSE_BLOCK>
The contents of this file are subject to the GNU Lesser General Public License
Expand Down
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
# Required to run on platform / side: [UNIX]
#
# Copyright (C) 2017 Sebastian M. Ernst <[email protected]>
# Copyright (C) 2017-2018 Sebastian M. Ernst <[email protected]>
#
# <LICENSE_BLOCK>
# The contents of this file are subject to the GNU Lesser General Public License
Expand Down
2 changes: 1 addition & 1 deletion scripts/wine-pip
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#
# Required to run on platform / side: [UNIX]
#
# Copyright (C) 2017 Sebastian M. Ernst <[email protected]>
# Copyright (C) 2017-2018 Sebastian M. Ernst <[email protected]>
#
# <LICENSE_BLOCK>
# The contents of this file are subject to the GNU Lesser General Public License
Expand Down
2 changes: 1 addition & 1 deletion scripts/wine-pytest
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#
# Required to run on platform / side: [UNIX]
#
# Copyright (C) 2017 Sebastian M. Ernst <[email protected]>
# Copyright (C) 2017-2018 Sebastian M. Ernst <[email protected]>
#
# <LICENSE_BLOCK>
# The contents of this file are subject to the GNU Lesser General Public License
Expand Down
2 changes: 1 addition & 1 deletion scripts/wine-python
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#
# Required to run on platform / side: [UNIX]
#
# Copyright (C) 2017 Sebastian M. Ernst <[email protected]>
# Copyright (C) 2017-2018 Sebastian M. Ernst <[email protected]>
#
# <LICENSE_BLOCK>
# The contents of this file are subject to the GNU Lesser General Public License
Expand Down
Loading

0 comments on commit 32db77f

Please sign in to comment.