Platforms and compilers

For what platforms is OFC targetted?

At the moment the platforms Linux, Ubuntu, FreeBSD and WIN32 are targetted.

With which compilers is OFC tested?

There are not a lot of Objective-C compilers around. OFC is tested on the Linux, Ubuntu and FreeBSD platform with the gcc compiler with Objective-C support. On the WIN32 platform MingW32 is used. OFC is not tested with CYGWIN.

Class structure

Does OFC use a base object

Yes, OFC uses the standard class Object as base object. OFC doesn't introduce an extra or another base class.

Memory management

Does OFC use reference counting?

No, OFC does not use reference counting. It introduces extra overhead and it will not always work correctly.

Can I use a garbage collector with OFC?

Well I didn't try it, but I can't see a reason why it shouldn't work.

How does the collections handle objects?

Collections store pointers to objects. They will not make copies before they store the objects. It is the decision of the programmer to make the collection the owner of the object or some other object. To support the programmer there are two 'free' methods in the collections:

How do the DAvlTree and DHashTable store keys?

DAvlTree and DHashTable copy the key before storing, to prevent that the key is changed outside the scope of the tree c.q. hashtable. As a result the key is always freed when the tree c.q. hashtable element is freed.

How do I copy objects?

The standard class Object implements four methods for coping objects:

Not all classes in the OFC library implements the shallowCopy method. If an object cannot be copied, a warning will be issued.
In the versions prior 0.7.1 the use of shallowCopy results in an object that shares private objects and dynamic variables with the original object. As a result freeing the original or the copied object could result in a seg-fault. In version 0.7.1 this is fixed.

Wrapper classes

Why is the wrapper class sometimes not named the same as the (external) library?

The name of the class is independant of the name of the external library to make it possible to change the external library. For every library it is possible that the development is discontinued or that there will be a beter alternative one day. By using a more general name for the wrapper class, there is a good chance that the underlying library can be changed, without consequences for the interface of the wrapper class.

Is it possible to check if a wrapper class is present?

Classes that depend on other (external) libraries, will set a define to indicate that the class is present in the OFC library. For example the class DRegEx defines HAVE_DREGEX if the class is present.

Error handling

What type of errors are identified by OFC?

There are three types of errors identified by OFC:

  1. Runtime errors related to Objective-C
    Examples: Method not implemented by a class, Out of memory.
  2. Programmer's errors
    Examples: Index out of range, invalid value for a method parameter.
  3. Environment errors
    Examples: File not found, connection unexpectedly closed.

How does OFC handle runtime errors?

OFC does not handle runtime errors. It is up to the programmer to set an error handler (using objc_error_handler) and handle the errors.

How does OFC handle programmer's errors?

OFC uses the concept of Garbage in, defined value out. So for example if the programmer uses an index that is out of range for an object, a warning is given and a valid (but possible incorrect) value is returned. There are a few exceptions: test methods will return the correctness of the parameter and will not give a warning, some parameters can not be checked (for example an invalid pointer) and only parameters of OFC methods will be checked.

How does OFC handle environment errors?

Methods in OFC handle environment errors by returning a boolean that indicates success (or failure) or returning an error code. The error code is comparable to the standard errno. Some classes also implement test methods and methods to get more information about the error.

Does OFC use exceptions?

In the current version OFC does not use exceptions.