Data Structures |
| struct | class |
Defines |
| #define | _ISOC99_SOURCE |
| #define | CLASS_MAGIC 0xFEFE |
| #define | CLASS(name) |
| #define | EXTENDS(parent) const char _[sizeof(struct c_##parent)] |
| #define | _NULL NULL |
| #define | CREATE_CLASS(name, _parent,...) |
| #define | INIT_CLASS(class) ((class)->init? (class)->init() : (class)) |
| #define | GET_CLASS(object) (INIT_CLASS(*(class_ptr *)((void*)(object) - sizeof(void*)))) |
| #define | IFACE_GET(class, iface) (interfaceGet(&((class)->impl),(iface))) |
| #define | HAS_PARENT(class) (NULL != ((class)->parent) && INIT_CLASS((class)->parent)) |
| #define | IS_OBJECT(obj) ((GET_CLASS((obj)))->magic == CLASS_MAGIC) |
| #define | INSTANCE_OF(class, obj) ((GET_CLASS((obj))) == _##class) |
| #define | _CALL(_class, _iface, method,...) |
| #define | CALL(object, _iface, method,...) |
| #define | RETCALL(object, _iface, method, ret,...) |
| #define | PARENTCALL(object, _iface, method,...) |
Typedefs |
| typedef struct class * | class_ptr |
| typedef class_ptr(* | fptr_classInit )(void) |
My own class implementation for C. It combines a data structure with a set of dynamically linked methods defined by an interface. A dynamically linked method will be called via a selector method which in turn gets the implementation stored in the class.
- Author:
- Georg Hopp
Copyright © 2012 Georg Hopp
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Definition in file class.h.