PHP Classes

File: ext/phady/version.zep.c

Recommend this page to a friend!
  Classes of Alien Fernandez   Phady Framework   ext/phady/version.zep.c   Download  
File: ext/phady/version.zep.c
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Phady Framework
Web application MVC framework based on Phalcon
Author: By
Last change:
Date: 8 years ago
Size: 7,563 bytes
 

Contents

Class file image Download
#ifdef HAVE_CONFIG_H #include "../ext_config.h" #endif #include <php.h> #include "../php_ext.h" #include "../ext.h" #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> #include "kernel/main.h" #include "kernel/array.h" #include "kernel/memory.h" #include "kernel/operators.h" #include "kernel/fcall.h" #include "kernel/concat.h" #include "kernel/string.h" /** * Phady\Version * * This class allows to get the installed version of the framework */ ZEPHIR_INIT_CLASS(Phady_Version) { ZEPHIR_REGISTER_CLASS(Phady, Version, phady, version, phady_version_method_entry, 0); /** * The constant referencing the major version. Returns 0 * <code> * echo Phady\Version::getPart(Phady\Version::VERSION_MAJOR); * </code> */ zend_declare_class_constant_long(phady_version_ce, SL("VERSION_MAJOR"), 0 TSRMLS_CC); /** * The constant referencing the major version. Returns 1 * <code> * echo Phady\Version::getPart(Phady\Version::VERSION_MEDIUM); * </code> */ zend_declare_class_constant_long(phady_version_ce, SL("VERSION_MEDIUM"), 1 TSRMLS_CC); /** * The constant referencing the major version. Returns 2 * <code> * echo Phady\Version::getPart(Phady\Version::VERSION_MINOR); * </code> */ zend_declare_class_constant_long(phady_version_ce, SL("VERSION_MINOR"), 2 TSRMLS_CC); /** * The constant referencing the major version. Returns 3 * <code> * echo Phady\Version::getPart(Phady\Version::VERSION_SPECIAL); * </code> */ zend_declare_class_constant_long(phady_version_ce, SL("VERSION_SPECIAL"), 3 TSRMLS_CC); /** * The constant referencing the major version. Returns 4 * <code> * echo Phady\Version::getPart(Phady\Version::VERSION_SPECIAL_NUMBER); * </code> */ zend_declare_class_constant_long(phady_version_ce, SL("VERSION_SPECIAL_NUMBER"), 4 TSRMLS_CC); return SUCCESS; } /** * Area where the version number is set. The format is as follows: * ABBCCDE * * A - Major version * B - Med version (two digits) * C - Min version (two digits) * D - Special release: 1 = Alpha, 2 = Beta, 3 = RC, 4 = Stable * E - Special release version i.e. RC1, Beta2 etc. */ PHP_METHOD(Phady_Version, _getVersion) { zval *_0 = NULL; ZEPHIR_MM_GROW(); zephir_create_array(return_value, 5, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 1); zephir_array_fast_append(return_value, _0); ZEPHIR_INIT_NVAR(_0); ZVAL_LONG(_0, 0); zephir_array_fast_append(return_value, _0); ZEPHIR_INIT_NVAR(_0); ZVAL_LONG(_0, 0); zephir_array_fast_append(return_value, _0); ZEPHIR_INIT_NVAR(_0); ZVAL_LONG(_0, 0); zephir_array_fast_append(return_value, _0); ZEPHIR_INIT_NVAR(_0); ZVAL_LONG(_0, 0); zephir_array_fast_append(return_value, _0); RETURN_MM(); } /** * Translates a number to a special release * * If Special release = 1 this function will return ALPHA * * @return string */ PHP_METHOD(Phady_Version, _getSpecial) { zval *special_param = NULL, *suffix = NULL; int special; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &special_param); special = zephir_get_intval(special_param); ZEPHIR_INIT_VAR(suffix); ZVAL_STRING(suffix, "", 1); do { if (special == 1) { ZEPHIR_INIT_NVAR(suffix); ZVAL_STRING(suffix, "ALPHA", 1); break; } if (special == 2) { ZEPHIR_INIT_NVAR(suffix); ZVAL_STRING(suffix, "BETA", 1); break; } if (special == 3) { ZEPHIR_INIT_NVAR(suffix); ZVAL_STRING(suffix, "RC", 1); break; } } while(0); RETURN_CCTOR(suffix); } /** * Returns the active version (string) * * <code> * echo Phady\Version::get(); * </code> * * @return string */ PHP_METHOD(Phady_Version, get) { zephir_fcall_cache_entry *_0 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *version = NULL, *major, *medium, *minor, *special, *specialNumber, *result, *suffix = NULL, *_1; ZEPHIR_MM_GROW(); ZEPHIR_CALL_SELF(&version, "_getversion", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_VAR(major); zephir_array_fetch_long(&major, version, 0, PH_NOISY, "phady/version.zep", 121 TSRMLS_CC); ZEPHIR_OBS_VAR(medium); zephir_array_fetch_long(&medium, version, 1, PH_NOISY, "phady/version.zep", 122 TSRMLS_CC); ZEPHIR_OBS_VAR(minor); zephir_array_fetch_long(&minor, version, 2, PH_NOISY, "phady/version.zep", 123 TSRMLS_CC); ZEPHIR_OBS_VAR(special); zephir_array_fetch_long(&special, version, 3, PH_NOISY, "phady/version.zep", 124 TSRMLS_CC); ZEPHIR_OBS_VAR(specialNumber); zephir_array_fetch_long(&specialNumber, version, 4, PH_NOISY, "phady/version.zep", 125 TSRMLS_CC); ZEPHIR_INIT_VAR(result); ZEPHIR_CONCAT_VSVSVS(result, major, ".", medium, ".", minor, " "); ZEPHIR_CALL_SELF(&suffix, "_getspecial", &_0, 158, special); zephir_check_call_status(); if (!ZEPHIR_IS_STRING(suffix, "")) { ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_VSV(_1, suffix, " ", specialNumber); zephir_concat_self(&result, _1 TSRMLS_CC); } zephir_fast_trim(return_value, result, NULL , ZEPHIR_TRIM_BOTH TSRMLS_CC); RETURN_MM(); } /** * Returns the numeric active version * * <code> * echo Phady\Version::getId(); * </code> * * @return string */ PHP_METHOD(Phady_Version, getId) { zephir_fcall_cache_entry *_2 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *version = NULL, *major, *medium, *minor, *special, *specialNumber, _0 = zval_used_for_init, *_1 = NULL, *_3 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_CALL_SELF(&version, "_getversion", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_VAR(major); zephir_array_fetch_long(&major, version, 0, PH_NOISY, "phady/version.zep", 153 TSRMLS_CC); ZEPHIR_OBS_VAR(medium); zephir_array_fetch_long(&medium, version, 1, PH_NOISY, "phady/version.zep", 154 TSRMLS_CC); ZEPHIR_OBS_VAR(minor); zephir_array_fetch_long(&minor, version, 2, PH_NOISY, "phady/version.zep", 155 TSRMLS_CC); ZEPHIR_OBS_VAR(special); zephir_array_fetch_long(&special, version, 3, PH_NOISY, "phady/version.zep", 156 TSRMLS_CC); ZEPHIR_OBS_VAR(specialNumber); zephir_array_fetch_long(&specialNumber, version, 4, PH_NOISY, "phady/version.zep", 157 TSRMLS_CC); ZEPHIR_SINIT_VAR(_0); ZVAL_STRING(&_0, "%02s", 0); ZEPHIR_CALL_FUNCTION(&_1, "sprintf", &_2, 8, &_0, medium); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_0); ZVAL_STRING(&_0, "%02s", 0); ZEPHIR_CALL_FUNCTION(&_3, "sprintf", &_2, 8, &_0, minor); zephir_check_call_status(); ZEPHIR_CONCAT_VVVVV(return_value, major, _1, _3, special, specialNumber); RETURN_MM(); } /** * Returns a specific part of the version. If the wrong parameter is passed * it will return the full version * * <code> * echo Phady\Version::getPart(Phady\Version::VERSION_MAJOR); * </code> * * @return string */ PHP_METHOD(Phady_Version, getPart) { zephir_fcall_cache_entry *_0 = NULL; zval *part_param = NULL, *version = NULL, *result = NULL, *_1; int part, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &part_param); part = zephir_get_intval(part_param); ZEPHIR_CALL_SELF(&version, "_getversion", NULL, 0); zephir_check_call_status(); do { if (part == 0 || part == 1 || part == 2 || part == 4) { ZEPHIR_OBS_VAR(result); zephir_array_fetch_long(&result, version, part, PH_NOISY, "phady/version.zep", 182 TSRMLS_CC); break; } if (part == 3) { zephir_array_fetch_long(&_1, version, 3, PH_NOISY | PH_READONLY, "phady/version.zep", 186 TSRMLS_CC); ZEPHIR_CALL_SELF(&result, "_getspecial", &_0, 158, _1); zephir_check_call_status(); break; } ZEPHIR_CALL_SELF(&result, "get", NULL, 0); zephir_check_call_status(); break; } while(0); RETURN_CCTOR(result); }