cengal.ctypes_tools.tools.versions.v_0.tools

 1#!/usr/bin/env python
 2# coding=utf-8
 3
 4# Copyright © 2012-2024 ButenkoMS. All rights reserved. Contacts: <gtalk@butenkoms.space>
 5# 
 6# Licensed under the Apache License, Version 2.0 (the "License");
 7# you may not use this file except in compliance with the License.
 8# You may obtain a copy of the License at
 9# 
10#     http://www.apache.org/licenses/LICENSE-2.0
11# 
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17
18
19__all__ = ['cfunc_def', 'ccfunc_def']
20
21
22from ctypes import CFUNCTYPE
23
24from typing import Any, Optional, Tuple
25
26
27"""
28Module Docstring
29Docstrings: http://www.python.org/dev/peps/pep-0257/
30"""
31
32__author__ = "ButenkoMS <gtalk@butenkoms.space>"
33__copyright__ = "Copyright © 2012-2024 ButenkoMS. All rights reserved. Contacts: <gtalk@butenkoms.space>"
34__credits__ = ["ButenkoMS <gtalk@butenkoms.space>", ]
35__license__ = "Apache License, Version 2.0"
36__version__ = "4.4.1"
37__maintainer__ = "ButenkoMS <gtalk@butenkoms.space>"
38__email__ = "gtalk@butenkoms.space"
39# __status__ = "Prototype"
40__status__ = "Development"
41# __status__ = "Production"
42
43
44def ccfunc_def(lib, func, params: Optional[Tuple], result: Optional[Any]) -> Any:
45    if params is None:
46        params = tuple()
47    
48    prototype = CFUNCTYPE(
49        result,
50        *params,
51    )
52    func = prototype((func, lib))
53    return func
54
55
56cfunc_def = ccfunc_def
def cfunc_def( lib, func, params: typing.Union[typing.Tuple, NoneType], result: typing.Union[typing.Any, NoneType]) -> Any:
45def ccfunc_def(lib, func, params: Optional[Tuple], result: Optional[Any]) -> Any:
46    if params is None:
47        params = tuple()
48    
49    prototype = CFUNCTYPE(
50        result,
51        *params,
52    )
53    func = prototype((func, lib))
54    return func
def ccfunc_def( lib, func, params: typing.Union[typing.Tuple, NoneType], result: typing.Union[typing.Any, NoneType]) -> Any:
45def ccfunc_def(lib, func, params: Optional[Tuple], result: Optional[Any]) -> Any:
46    if params is None:
47        params = tuple()
48    
49    prototype = CFUNCTYPE(
50        result,
51        *params,
52    )
53    func = prototype((func, lib))
54    return func