IdentifiableObject.c

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2006-2007 by Konstantin V. Arkhipov                     *
00003  *                                                                         *
00004  *   This program is free software; you can redistribute it and/or modify  *
00005  *   it under the terms of the GNU Lesser General Public License as        *
00006  *   published by the Free Software Foundation; either version 3 of the    *
00007  *   License, or (at your option) any later version.                       *
00008  *                                                                         *
00009  ***************************************************************************/
00010 /* $Id: IdentifiableObject.c 4687 2007-12-09 18:57:18Z voxus $ */
00011 
00012 #include "onphp.h"
00013 
00014 #include "core/Base/Identifier.h"
00015 #include "core/Base/IdentifiableObject.h"
00016 
00017 ONPHP_METHOD(IdentifiableObject, wrap)
00018 {
00019     zval *object, *id;
00020 
00021     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &id) == FAILURE) {
00022         WRONG_PARAM_COUNT;
00023     }
00024 
00025     MAKE_STD_ZVAL(object);
00026 
00027     object->value.obj = onphp_empty_object_new(onphp_ce_IdentifiableObject TSRMLS_CC);
00028     Z_TYPE_P(object) = IS_OBJECT;
00029     
00030     ONPHP_UPDATE_PROPERTY(object, "id", id);
00031     
00032     RETURN_ZVAL(object, 1, 1);
00033 }
00034 
00035 ONPHP_METHOD(IdentifiableObject, getId)
00036 {
00037     zval *id;
00038 
00039     id = ONPHP_READ_PROPERTY(getThis(), "id");
00040 
00041     if (
00042         Z_TYPE_P(id) == IS_OBJECT
00043         && instanceof_function(Z_OBJCE_P(id), onphp_ce_Identifier TSRMLS_CC)
00044     ) {
00045         if (
00046             zval_is_true(ONPHP_READ_PROPERTY(id, "final"))
00047         ) {
00048             id = ONPHP_READ_PROPERTY(id, "id");
00049         }
00050     }
00051 
00052     RETURN_ZVAL(id, 1, 0);
00053 }
00054 
00055 ONPHP_METHOD(IdentifiableObject, setId)
00056 {
00057     zval *id;
00058     
00059     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &id) == FAILURE) {
00060         WRONG_PARAM_COUNT;
00061     }
00062 
00063     ONPHP_UPDATE_PROPERTY(getThis(), "id", id);
00064 
00065     RETURN_ZVAL(getThis(), 1, 0);
00066 }
00067 
00068 static ONPHP_ARGINFO_ONE;
00069 
00070 zend_function_entry onphp_funcs_IdentifiableObject[] = {
00071     ONPHP_ME(IdentifiableObject, getId, NULL, ZEND_ACC_PUBLIC)
00072     ONPHP_ME(IdentifiableObject, setId, arginfo_one, ZEND_ACC_PUBLIC)
00073     ONPHP_ME(IdentifiableObject, wrap,  arginfo_one, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
00074     {NULL, NULL, NULL}
00075 };

Generated on Sun Dec 9 21:56:23 2007 for onPHP by  doxygen 1.5.4