Metadata-Version: 2.1
Name: objc-types-decoder
Version: 0.0.5
Summary: A type decoder for Objective-C types
Author-email: matan <matan1008@gmail.com>
Maintainer-email: matan <matan1008@gmail.com>
License: MIT License
        
        Copyright (c) 2021 Matan Perelman
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/matan1008/objc-types-decoder
Project-URL: Bug Reports, https://github.com/matan1008/objc-types-decoder/issues
Keywords: ios,Objective-C
Classifier: Development Status :: 5 - Production/Stable
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3 :: Only
Requires-Python: >=3.7
Description-Content-Type: text/markdown
Provides-Extra: test
License-File: LICENSE

# objc-types-decoder

[![Python application](https://github.com/matan1008/objc-types-decoder/workflows/Python%20application/badge.svg)](https://github.com/matan1008/objc-types-decoder/actions/workflows/python-app.yml "Python application action")
[![Pypi version](https://img.shields.io/pypi/v/objc-types-decoder.svg)](https://pypi.org/project/objc-types-decoder/ "PyPi package")
[![Downloads](https://static.pepy.tech/personalized-badge/objc-types-decoder?period=total&units=none&left_color=grey&right_color=blue&left_text=Downloads)](https://pepy.tech/project/objc-types-decoder)


A type decoder for Objective-C types.

It translates the encoded Objective-C type notation, the notation that the `@encode` function returns, into a readable
form that tries to be as close as possible to the original type definition.

For example, lets look at the following `@encode`:

```objective-c
NSLog(@"%s", @encode(float **)); // "^^f" will be printed.
```

Using our decoder, we can "reverse" the process:

```python
from objc_types_decoder.decode import decode

print(decode('^^f'))  # 'float * *' will be printed.
```

## Installation

In order to install this package, just use a regular `pip` installation:

```shell
pip install objc_types_decoder
```

## Usage

In order to use the decoder, just run the main with your desired encoded type:

```shell
>> py -m objc_types_decoder ^f
float *
```

You can also decode by importing it in your python code:

```python
>> from objc_types_decoder.decode import decode
>> decode('{NSObject=#}')
'struct NSObject { Class x0; }'
```

Sometimes, you might want to keep the tail of the parsed data. For this case, you can use `decode_with_tail`.

```python
>> from objc_types_decoder.decode import decode_with_tail
>> decode_with_tail('fyour boat')
('float', 'your boat')
```

