Skip to main content

A type decoder for Objective-C types

Project description

objc-types-decoder

Python application Pypi version Downloads

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:

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

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

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:

pip install objc_types_decoder

Usage

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

>> py -m objc_types_decoder ^f
float *

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

>> 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.

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

objc_types_decoder-0.0.5.tar.gz (5.8 kB view hashes)

Uploaded Source

Built Distribution

objc_types_decoder-0.0.5-py3-none-any.whl (6.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page