Metadata-Version: 2.0
Name: rubicon-objc
Version: 0.1.0
Summary: A bridge between an Objective C runtime environment and Python.
Home-page: http://pybee.org/rubicon
Author: Russell Keith-Magee
Author-email: russell@keith-magee.com
License: New BSD
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Objective C
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: User Interfaces
Classifier: Topic :: Software Development :: Widget Sets

Rubicon-ObjC
============

Rubicon-ObjC is a bridge between Objective C and Python. It enables you to:

* Use Python to instantiate objects defined in Objective C
* Use Python to invoke methods on objects defined in Objective C
* Subclass and extend Objective C classes in Python

It also includes wrappers of the some key data types from the Core Foundation
framework (e.g., NSString).

Quickstart
----------

Rubicon uses a combination of `ctypes`, plus Objective-C's own reflection
APIs, to enable Objective C objects to be referenced in a Python process.

To install Rubicon, use pip::

    $ pip install rubicon-objc

Then, in a Python shell::

    >>> from ctypes import cdll
    >>> from ctypes import util
    >>> from rubicon.objc import ObjCClass, ObjCSubclass, at, to_str

    # Use ctypes to import a framework into the Python process
    >>> cdll.LoadLibrary(util.find_library('Foundation'))

    # Wrap an Objective C class contained in the framework
    >>> NSURL = ObjCClass("NSURL")

    # Then instantiate the Objective C class, using the API
    # that is exposed through Objective C. The Python method name
    # is the concatenated version of the Objective C method descriptor,
    # with colons replaced with underscores. So, the equivalent of
    # [NSURL URLWithString:@"http://pybee.org"];
    # would be:
    >>> NSURL.URLWithString_("http://pybee.org/")

    # To create a new Objective C class, define a Python class that
    # has the methods you want to define:
    >>> class Handler_impl(object):
    ...     Handler = ObjCSubclass('NSObject', 'Handler')
    ...
    ...     @Handler.method('@i')
    ...     def initWithValue_(self, value):
    ...         # You can't store attributes directly on the object -
    ...         # you need to put them manually on the Python object
    ...         self.__dict__['value'] = value
    ...         return self
    ...
    ...     @Handler.method('vi')
    ...     def pokeWithValue_(self, value):
    ...         print ("Poking with", value)

    # Then, create a wrapper for that class...
    >>> Handler = ObjCClass('Handler')

    # ...and use it:
    >>> my_handler = Handler.alloc().initWithValue_(42)
    >>> my_handler.pokeWithValue_(37)

.. Documentation
.. -------------

.. Full documentation for Rubicon can be found on `Read The Docs`_.

Community
---------

Rubicon is part of the `BeeWare suite`_. You can talk to the community through:

* `@pybeeware on Twitter`_

* The `BeeWare Users Mailing list`_, for questions about how to use the BeeWare suite.

* The `BeeWare Developers Mailing list`_, for discussing the development of new features in the BeeWare suite, and ideas for new tools for the suite.

Contributing
------------

If you experience problems with this backend, `log them on GitHub`_. If you
want to contribute code, please `fork the code`_ and `submit a pull request`_.

.. _BeeWare suite: http://pybee.org
.. _Read The Docs: http://rubicon-objc.readthedocs.org
.. _@pybeeware on Twitter: https://twitter.com/pybeeware
.. _BeeWare Users Mailing list: https://groups.google.com/forum/#!forum/beeware-users
.. _BeeWare Developers Mailing list: https://groups.google.com/forum/#!forum/beeware-developers
.. _log them on Github: https://github.com/pybee/rubicon-objc/issues
.. _fork the code: https://github.com/pybee/rubicon-objc
.. _submit a pull request: https://github.com/pybee/rubicon-objc/pulls


