Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Important changes to objLib

2010-01-01
2013-04-22
  • The object library macro OBJ_VERIFY(objId, classId) has been enhanced. To verify an object, give a pointer to the structure which has been instantiated from the class in question.

    It works like this:

    1. In order for a data structure to be an instance of a class it must contain one field:`typedef struct { …; OBJ_CORE objCore; …} ObjC;` **Please note that this field can be at any position in the data structure.**
    2. There must be a global class identifier varable: `OBJ_CLASS class;` and a pointer to it which will be used to identify the class later: `CLASS_ID classId = &class;`
    3. The class must be initialized before any other calls to objLib can be made: `classInit(classId, sizeof(ObjC),OFFSET(ObjC,objCore),…)`  **Please note that the class library will store the position of the object core field in the data structure internally. There is no need to send a pointer to in the object verify macro anymore.**
    4. Every object should initialize the object core field itself: `objCoreInit(&objC->objCore, classId);`
    5. Whenever the object shall be verified as an instance of the class, do the following: `if (OBJ_VERIFY(objId, classId) != OK) /* Invalid object */`