вторник, 24 января 2012 г.

CleanCF: CoreFoundation refactored


As I mentioned earlier, Itoa uses Apple's CoreFoundation to implement corresponding Foundation classes.

However, I found CoreFoundation library hard to work with. It was big and messy, and contained things I didn't need. So I decided to refactor it.

Welcome CleanCF, a refactored CoreFoundation!

воскресенье, 22 января 2012 г.

Licensing model

Itoa is open source, and its true -- code is available, all under open-source licenses.

But there is a catch - GPL license of itoa-main is incompatible with APSL license used in other projects. So you can't distribute applications built with Itoa. You can however, develop and use them privately (i.e. for testing).

Unless, of course, you obtain commercial license for itoa-main. That's right - itoa-main is dual-licensed.

However, you can't buy a license. Currently the only way to get a license is to contribute to Itoa. You can contribute to any of Itoa projects, not just itoa-main. But if you contribute to itoa-main I will need your assent to use your code whatever I like (retaining notice that code is written by you).

Current license contribution rules are: contribute anything and you will get a license. As simple as that.


In the future, once Itoa matures, commercial licenses will be available for purchase.

четверг, 19 января 2012 г.

Itoa's approach to Foundation library

Let me put it straight -- Itoa gives up possibility to inherit from some Foundation classes in favor of compatible implementation based on Apple's CoreFoundation.

Now for the explanation.

There are two approaches to implement CoreFoundation and Foundation libraries:
  1. Apple's approach. Implement both CoreFoundation and Foundation libraries. Base small portion of Foundation classes on CF (e.g. NSString, NSNumber), implement toll-free bridging to wire up two libraries.
  2. GNUStep/Cocotron's approach. Implement Foundation library only. Make CoreFoundation classes/functions to be simple wrappers around corresponding Foundation classes.

среда, 18 января 2012 г.

Introduction

Ever wanted to "just rebuild" your iOS app for Android?

Itoa project is just about that. It is a cluster of open-source projects hosted on Github that implement compiler, build scripts and various libraries to allow building Android's apk from Objective-C source files.

Two main features of Itoa are:
  1. Itoa uses Android UI and graphics classes to implement iOS counterparts, so ported applications look and feel native. For example, UIButton wraps android.widged.Button and CGContext wraps android.graphics.Canvas.
  2. Itoa uses Apple's open-source code (GCC patches for Objective-C 2.0, objc4 runtime and CoreFoundation library) for maximum compatibility with iOS.
Here is a short overview of Itoa projects with their licenses:
  • itoa-main :: ItoaCore, UIKit, CoreGraphics and QuartzCore libraries (GPL).
  • itoa-foundation :: Foundation implementation based on Cocotron (MIT).
  • itoa-cleancf :: Refactored Apple's CoreFoundation; supports bridging (APSL, Apache).
  • itoa-objc :: Apple's objc4 runtime ported to Android (APSL, Apache).
  • itoa-jnipp :: General purpose C++ JNI wrappers (Apache).
  • itoa-macemu :: Emulation of malloc_zone_t functions and OSAtomics (Apache).
  • itoa-dropins :: Various utilities (notably, a C++ wrappers for pthread) used in projects (Apache).
  • itoa-toolchain :: GCC 4.2.1 with Objective-C 2.0 patches (GPL).
  • itoa-ndk :: Scripts to build, install and run Android applications from Objective-C source files (Apache).


Current status of Itoa is best described as "first step on a journey of thousands miles": something is working (you can even build simple applications), but anything serious is not possible, due to missing libraries, incomplete API, insufficient Android integration, etc.

Project statuses at a glance:
  • GCC 4.2.1 compiler (3/5): supports most of Objective-C 2.0, but is outdated, and some features are missing (@optional directive, blocks).
  • Objective-C runtime (4/5): supports all features (except for GC), though some cleanup and refactoring is needed.
  • CoreFoundation library (2/5): all basic classes are there (CFString, CFArray, CFSet, etc.), but several essential classes are not (CFBundle, CFSocket, etc.). Besides, there is no Android integration.
  • Foundation library (2/5): while most of the classes are there (since implementation is based on Cocotron), only two classes are bridged to CF (NSString, NSData). Some classes are not working properly (NSRunLoop, NSInvocation). No integration with Android.
  • QuartzCore library (0/5): only CALayer class is implemented.
  • UIKit library (1/5): only basic classes are implemented (UIApplication, UIResponder, UIView, etc.). Multitouch is not supported. Nibs not supported.
  • CoreGraphics library (0/5): GCColor, GCRect plus minimal implementation of CGContext.

That's it for the introductory post. In the next posts I will cover status of each project in more detail and propose tasks to do. I will also describe hacks currently employed (like running Android's loop inside CFRunLoop and using Android's ICU).

Give Itoa a try and let me know what you think (here or in itoa-dev group). Links: