Pajdeg  0.2.2
Pajdeg
Files | Macros | Functions
PDType

The generic Pajdeg object type. More...

Files

file  PDType.h
 

Macros

#define PDReleaseFunc   PDRelease
 
#define PDDebugBeginSession()
 
#define PDDebugEndSession()   0
 
#define PDFlagGlobalObject(ob)
 

Functions

void PDRelease (void *pajdegObject)
 
void * PDRetain (void *pajdegObject)
 
void * PDAutorelease (void *pajdegObject)
 
PDInstanceType PDResolve (void *pajdegObject)
 
const char * PDDescription (void *pajdegObject)
 

Detailed Description

The generic Pajdeg object type.

PDType provides the release and retain functionality to Pajdeg objects.

Warning
Not all types in Pajdeg are Pajdeg objects. An object whose type is camel case and begins with capital PD is always a Pajdeg object, and can be retained and released, whereas objects using underscore separation in all lower case are non-Pajdeg objects (used by the Pajdeg system), such as pd_btree. The exception to this is primitive objects, such as PDInteger, PDBool, etc., and PDType itself.

Concept behind Release and Retain

Releasing and retaining is a method for structuring memory management, and is used e.g. in Objective-C and other languages. The concept is fairly straightforward:

There are also instances where an object will become invalid in the middle of a function body, if it is released and has no pending autorelease calls.

For example, the following code snippet shows how this works:

The PDPipe object is retained because the function name has the word Create in it, so it must be released.

The PDParser is not retained, as we obtained it through a function whose name did not contain Create – consequently, the parser variable must not be released as we don't own a reference to it.

The meta object must be released by us, as it has the word Create.

Function Documentation

void* PDAutorelease ( void *  pajdegObject)

Autorelease a Pajdeg object.

Even if the caller was the last referrer, the object will not be destroyed until the PDPipeExecute() iteration for the current object has ended.

Thus, it is possible to return an object with a zero retain count by autoreleasing it.

Parameters
pajdegObjectThe object that should, at some point, be released once.
const char* PDDescription ( void *  pajdegObject)

Generate a description of the given object as a C string. The description is generated via the PDInstancePrinters entry for the resolved instance type of the object.

Parameters
pajdegObjectObject whose C string description should be generated
Returns
An "autoreleased" string.
void PDRelease ( void *  pajdegObject)

Release a Pajdeg object.

If the caller was the last referrer, the object will be destroyed immediately.

Parameters
pajdegObjectA previously retained or created PD object.
PDInstanceType PDResolve ( void *  pajdegObject)

Resolve the PDInstanceType of the given object.

Parameters
pajdegObjectThe object whose type should be resolved
Returns
PDInstanceType for the given object
void* PDRetain ( void *  pajdegObject)

Retain a Pajdeg object.

Parameters
pajdegObjectA PD object.