/***************************** {{{ LICENSE ********************************\ * dbobj, the relational object persistence module for PHP * * Copyright (C) 2006 Adam Banko * * * * 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 2 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, write to the Free Software * * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * \***************************** LICENSE }}} ********************************/ #ifndef DBOBJ_objType_H #define DBOBJ_objType_H #include "php_dbobj.h" //Java-like objects typedef struct _objVal *objVal; //abstract typedef objVal basicVal; //basicVal is a subclass of objVal (still abstract) typedef objVal complexVal; //complexVal is a subclass of objVal (still abstract) typedef struct _objType *objType; typedef objType basicType; //basicType is a subclass of objType (currently equal) typedef struct _complexType *complexType; //complexType is a subclass of objType typedef objVal (*zVal2objVal_t)(objType type, zval* zv TSRMLS_DC); typedef zval* (*objVal2zVal_t)(objType type, objVal this TSRMLS_DC); typedef void (*objVal_dtor_t)(objType type, objVal this TSRMLS_DC); typedef void (*objType_dtor_t)(objType type TSRMLS_DC); typedef struct _objType_vtable { zVal2objVal_t zVal2objVal; objVal2zVal_t objVal2zVal; objVal_dtor_t objVal_dtor; objType_dtor_t objType_dtor; } objType_vtable; #define OBJTYPE_COMMON \ objType_vtable *vt struct _objType { OBJTYPE_COMMON; char __[]; //variable lenght struct (abstract class) }; /* * complexTypes can freely choose how to store their source types * it may have different vtables for different sources or store the type data in a property and use them in big swithes */ typedef basicVal* (*complexVal2basicVals_t)(complexType type, complexVal this TSRMLS_DC); typedef complexVal (*basicVals2complexVal_t)(complexType type, basicVal sourceVals[] TSRMLS_DC); typedef struct _complexType_vtable { zVal2objVal_t zVal2objVal; objVal2zVal_t objVal2zVal; objVal_dtor_t objVal_dtor; objType_dtor_t objType_dtor; basicVals2complexVal_t basicVals2complexVal; complexVal2basicVals_t complexVal2basicVals; } complexType_vtable; #define COMPLEXTYPE_COMMON \ complexType_vtable *vt struct _complexType { COMPLEXTYPE_COMMON; char __[]; //variable lenght struct (abstract class) }; //FIXME check all child classes return values: emalloc or pemalloc? //values should be allocated with emalloc, types with pemalloc #endif //DBOBJ_objType_H /* * vim600: noet sw=4 ts=4 fdm=marker * vim<600: noet sw=4 ts=4 */