├── ext ├── .deps ├── missing ├── install-sh ├── mkinstalldirs ├── Makefile.fragments ├── .libs │ ├── jalali.la │ ├── jalali.o │ ├── jalali.so │ └── jalali.lai ├── build │ ├── shtool │ ├── scan_makefile_in.awk │ ├── ltversion.m4 │ ├── mkdep.awk │ ├── ltsugar.m4 │ └── lt~obsolete.m4 ├── modules │ └── jalali.so ├── ext_config.h ├── jalali │ ├── .libs │ │ └── date.o │ ├── date.lo │ └── date.zep.h ├── kernel │ ├── .libs │ │ ├── exit.o │ │ ├── file.o │ │ ├── hash.o │ │ ├── main.o │ │ ├── array.o │ │ ├── concat.o │ │ ├── debug.o │ │ ├── fcall.o │ │ ├── filter.o │ │ ├── memory.o │ │ ├── object.o │ │ ├── require.o │ │ ├── string.o │ │ ├── backtrace.o │ │ ├── exception.o │ │ ├── iterator.o │ │ ├── operators.o │ │ └── variables.o │ ├── extended │ │ ├── .libs │ │ │ └── array.o │ │ ├── array.lo │ │ ├── array.c │ │ └── array.h │ ├── array.lo │ ├── debug.lo │ ├── exit.lo │ ├── fcall.lo │ ├── file.lo │ ├── hash.lo │ ├── main.lo │ ├── concat.lo │ ├── filter.lo │ ├── memory.lo │ ├── object.lo │ ├── string.lo │ ├── iterator.lo │ ├── require.lo │ ├── backtrace.lo │ ├── exception.lo │ ├── operators.lo │ ├── variables.lo │ ├── concat.h │ ├── exit.h │ ├── persistent.h │ ├── iterator.h │ ├── assert.h │ ├── README.md │ ├── backtrace.h │ ├── variables.h │ ├── session.h │ ├── exit.c │ ├── output.h │ ├── filter.h │ ├── assert.c │ ├── iterator.c │ ├── require.h │ ├── persistent.c │ ├── backtrace.c │ ├── debug.h │ ├── file.h │ ├── hash.h │ ├── session.c │ ├── exception.h │ ├── variables.c │ ├── output.c │ ├── require.c │ ├── array.h │ ├── exception.c │ ├── globals.h │ ├── string.h │ ├── concat.c │ ├── memory.h │ ├── debug.c │ ├── filter.c │ ├── hash.c │ └── operators.h ├── ext.h ├── php_ext.h ├── clean ├── config.nice ├── jalali.h ├── install ├── jalali.lo ├── jalali.la ├── config.m4 ├── php_jalali.h ├── config.h.in ├── config.h ├── autom4te.cache │ └── requests ├── configure.in ├── Makefile.objects ├── Makefile.global └── jalali.c ├── .gitignore ├── examples └── formatter.php ├── composer.json ├── LICENSE ├── config.json └── README.md /ext/.deps: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ext/missing: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ext/install-sh: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ext/mkinstalldirs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ext/Makefile.fragments: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ext/.libs/jalali.la: -------------------------------------------------------------------------------- 1 | ../jalali.la -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor/ 2 | .temp 3 | *.log -------------------------------------------------------------------------------- /ext/build/shtool: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohebifar/php-jalali-extension/HEAD/ext/build/shtool -------------------------------------------------------------------------------- /ext/.libs/jalali.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohebifar/php-jalali-extension/HEAD/ext/.libs/jalali.o -------------------------------------------------------------------------------- /ext/.libs/jalali.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohebifar/php-jalali-extension/HEAD/ext/.libs/jalali.so -------------------------------------------------------------------------------- /ext/modules/jalali.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohebifar/php-jalali-extension/HEAD/ext/modules/jalali.so -------------------------------------------------------------------------------- /ext/ext_config.h: -------------------------------------------------------------------------------- 1 | /* This file was generated automatically by Zephir do not modify it! */ 2 | #include "config.h" -------------------------------------------------------------------------------- /ext/jalali/.libs/date.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohebifar/php-jalali-extension/HEAD/ext/jalali/.libs/date.o -------------------------------------------------------------------------------- /ext/kernel/.libs/exit.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohebifar/php-jalali-extension/HEAD/ext/kernel/.libs/exit.o -------------------------------------------------------------------------------- /ext/kernel/.libs/file.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohebifar/php-jalali-extension/HEAD/ext/kernel/.libs/file.o -------------------------------------------------------------------------------- /ext/kernel/.libs/hash.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohebifar/php-jalali-extension/HEAD/ext/kernel/.libs/hash.o -------------------------------------------------------------------------------- /ext/kernel/.libs/main.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohebifar/php-jalali-extension/HEAD/ext/kernel/.libs/main.o -------------------------------------------------------------------------------- /ext/ext.h: -------------------------------------------------------------------------------- 1 | 2 | /* This file was generated automatically by Zephir do not modify it! */ 3 | 4 | #include "jalali.h" -------------------------------------------------------------------------------- /ext/kernel/.libs/array.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohebifar/php-jalali-extension/HEAD/ext/kernel/.libs/array.o -------------------------------------------------------------------------------- /ext/kernel/.libs/concat.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohebifar/php-jalali-extension/HEAD/ext/kernel/.libs/concat.o -------------------------------------------------------------------------------- /ext/kernel/.libs/debug.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohebifar/php-jalali-extension/HEAD/ext/kernel/.libs/debug.o -------------------------------------------------------------------------------- /ext/kernel/.libs/fcall.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohebifar/php-jalali-extension/HEAD/ext/kernel/.libs/fcall.o -------------------------------------------------------------------------------- /ext/kernel/.libs/filter.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohebifar/php-jalali-extension/HEAD/ext/kernel/.libs/filter.o -------------------------------------------------------------------------------- /ext/kernel/.libs/memory.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohebifar/php-jalali-extension/HEAD/ext/kernel/.libs/memory.o -------------------------------------------------------------------------------- /ext/kernel/.libs/object.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohebifar/php-jalali-extension/HEAD/ext/kernel/.libs/object.o -------------------------------------------------------------------------------- /ext/kernel/.libs/require.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohebifar/php-jalali-extension/HEAD/ext/kernel/.libs/require.o -------------------------------------------------------------------------------- /ext/kernel/.libs/string.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohebifar/php-jalali-extension/HEAD/ext/kernel/.libs/string.o -------------------------------------------------------------------------------- /ext/kernel/.libs/backtrace.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohebifar/php-jalali-extension/HEAD/ext/kernel/.libs/backtrace.o -------------------------------------------------------------------------------- /ext/kernel/.libs/exception.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohebifar/php-jalali-extension/HEAD/ext/kernel/.libs/exception.o -------------------------------------------------------------------------------- /ext/kernel/.libs/iterator.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohebifar/php-jalali-extension/HEAD/ext/kernel/.libs/iterator.o -------------------------------------------------------------------------------- /ext/kernel/.libs/operators.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohebifar/php-jalali-extension/HEAD/ext/kernel/.libs/operators.o -------------------------------------------------------------------------------- /ext/kernel/.libs/variables.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohebifar/php-jalali-extension/HEAD/ext/kernel/.libs/variables.o -------------------------------------------------------------------------------- /ext/php_ext.h: -------------------------------------------------------------------------------- 1 | 2 | /* This file was generated automatically by Zephir do not modify it! */ 3 | 4 | #include "php_jalali.h" -------------------------------------------------------------------------------- /ext/kernel/extended/.libs/array.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mohebifar/php-jalali-extension/HEAD/ext/kernel/extended/.libs/array.o -------------------------------------------------------------------------------- /ext/clean: -------------------------------------------------------------------------------- 1 | for i in `find . -name "*.o"`; do 2 | rm -f $i 3 | done 4 | for i in `find . -name "*.lo"`; do 5 | rm -f $i 6 | done 7 | make clean 8 | phpize --clean 9 | -------------------------------------------------------------------------------- /ext/config.nice: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # Created by configure 4 | 5 | CFLAGS='-O2 -fvisibility=hidden -Wparentheses -flto' \ 6 | CC='gcc' \ 7 | './configure' \ 8 | '--enable-jalali' \ 9 | "$@" 10 | -------------------------------------------------------------------------------- /ext/jalali.h: -------------------------------------------------------------------------------- 1 | 2 | /* This file was generated automatically by Zephir do not modify it! */ 3 | 4 | #ifndef ZEPHIR_CLASS_ENTRIES_H 5 | #define ZEPHIR_CLASS_ENTRIES_H 6 | 7 | #include "jalali/date.zep.h" 8 | 9 | #endif -------------------------------------------------------------------------------- /examples/formatter.php: -------------------------------------------------------------------------------- 1 | date('Y m d'); 10 | -------------------------------------------------------------------------------- /ext/install: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | export CC="gcc" 3 | export CFLAGS="-O2 -Wall -fvisibility=hidden -flt" 4 | if [ -f Makefile ]; then 5 | sudo make --silent clean 6 | sudo phpize --silent --clean 7 | fi 8 | phpize --silent 9 | ./configure --silent --enable-jalali 10 | make --silent && sudo make --silent install 11 | -------------------------------------------------------------------------------- /ext/jalali.lo: -------------------------------------------------------------------------------- 1 | # jalali.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.2 Debian-2.4.2-1.7ubuntu1 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/jalali.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object=none 12 | 13 | -------------------------------------------------------------------------------- /ext/jalali/date.lo: -------------------------------------------------------------------------------- 1 | # jalali/date.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.2 Debian-2.4.2-1.7ubuntu1 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/date.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object=none 12 | 13 | -------------------------------------------------------------------------------- /ext/kernel/array.lo: -------------------------------------------------------------------------------- 1 | # kernel/array.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.2 Debian-2.4.2-1.7ubuntu1 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/array.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object=none 12 | 13 | -------------------------------------------------------------------------------- /ext/kernel/debug.lo: -------------------------------------------------------------------------------- 1 | # kernel/debug.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.2 Debian-2.4.2-1.7ubuntu1 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/debug.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object=none 12 | 13 | -------------------------------------------------------------------------------- /ext/kernel/exit.lo: -------------------------------------------------------------------------------- 1 | # kernel/exit.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.2 Debian-2.4.2-1.7ubuntu1 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/exit.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object=none 12 | 13 | -------------------------------------------------------------------------------- /ext/kernel/fcall.lo: -------------------------------------------------------------------------------- 1 | # kernel/fcall.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.2 Debian-2.4.2-1.7ubuntu1 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/fcall.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object=none 12 | 13 | -------------------------------------------------------------------------------- /ext/kernel/file.lo: -------------------------------------------------------------------------------- 1 | # kernel/file.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.2 Debian-2.4.2-1.7ubuntu1 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/file.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object=none 12 | 13 | -------------------------------------------------------------------------------- /ext/kernel/hash.lo: -------------------------------------------------------------------------------- 1 | # kernel/hash.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.2 Debian-2.4.2-1.7ubuntu1 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/hash.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object=none 12 | 13 | -------------------------------------------------------------------------------- /ext/kernel/main.lo: -------------------------------------------------------------------------------- 1 | # kernel/main.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.2 Debian-2.4.2-1.7ubuntu1 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/main.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object=none 12 | 13 | -------------------------------------------------------------------------------- /ext/kernel/concat.lo: -------------------------------------------------------------------------------- 1 | # kernel/concat.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.2 Debian-2.4.2-1.7ubuntu1 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/concat.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object=none 12 | 13 | -------------------------------------------------------------------------------- /ext/kernel/filter.lo: -------------------------------------------------------------------------------- 1 | # kernel/filter.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.2 Debian-2.4.2-1.7ubuntu1 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/filter.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object=none 12 | 13 | -------------------------------------------------------------------------------- /ext/kernel/memory.lo: -------------------------------------------------------------------------------- 1 | # kernel/memory.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.2 Debian-2.4.2-1.7ubuntu1 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/memory.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object=none 12 | 13 | -------------------------------------------------------------------------------- /ext/kernel/object.lo: -------------------------------------------------------------------------------- 1 | # kernel/object.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.2 Debian-2.4.2-1.7ubuntu1 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/object.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object=none 12 | 13 | -------------------------------------------------------------------------------- /ext/kernel/string.lo: -------------------------------------------------------------------------------- 1 | # kernel/string.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.2 Debian-2.4.2-1.7ubuntu1 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/string.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object=none 12 | 13 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mohebifar/phpjalali", 3 | "description": "A php extension written in C for Jalali date calendar with php class fallback", 4 | "license": "MIT", 5 | "authors": [ 6 | { 7 | "name": "Mohamad Mohebifar", 8 | "email": "mohamad@mohebifar.com" 9 | } 10 | ], 11 | "require": {} 12 | } 13 | -------------------------------------------------------------------------------- /ext/kernel/iterator.lo: -------------------------------------------------------------------------------- 1 | # kernel/iterator.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.2 Debian-2.4.2-1.7ubuntu1 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/iterator.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object=none 12 | 13 | -------------------------------------------------------------------------------- /ext/kernel/require.lo: -------------------------------------------------------------------------------- 1 | # kernel/require.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.2 Debian-2.4.2-1.7ubuntu1 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/require.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object=none 12 | 13 | -------------------------------------------------------------------------------- /ext/kernel/backtrace.lo: -------------------------------------------------------------------------------- 1 | # kernel/backtrace.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.2 Debian-2.4.2-1.7ubuntu1 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/backtrace.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object=none 12 | 13 | -------------------------------------------------------------------------------- /ext/kernel/exception.lo: -------------------------------------------------------------------------------- 1 | # kernel/exception.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.2 Debian-2.4.2-1.7ubuntu1 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/exception.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object=none 12 | 13 | -------------------------------------------------------------------------------- /ext/kernel/operators.lo: -------------------------------------------------------------------------------- 1 | # kernel/operators.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.2 Debian-2.4.2-1.7ubuntu1 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/operators.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object=none 12 | 13 | -------------------------------------------------------------------------------- /ext/kernel/variables.lo: -------------------------------------------------------------------------------- 1 | # kernel/variables.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.2 Debian-2.4.2-1.7ubuntu1 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/variables.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object=none 12 | 13 | -------------------------------------------------------------------------------- /ext/kernel/extended/array.lo: -------------------------------------------------------------------------------- 1 | # kernel/extended/array.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.2 Debian-2.4.2-1.7ubuntu1 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/array.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object=none 12 | 13 | -------------------------------------------------------------------------------- /ext/build/scan_makefile_in.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | mode=0 3 | sources="" 4 | } 5 | 6 | mode == 0 && /^LTLIBRARY_SOURCES.*\\$/ { 7 | if (match($0, "[^=]*$")) { 8 | sources=substr($0, RSTART, RLENGTH-1) 9 | } 10 | mode=1 11 | next 12 | } 13 | 14 | mode == 0 && /^LTLIBRARY_SOURCES.*/ { 15 | if (match($0, "[^=]*$")) { 16 | sources=substr($0, RSTART, RLENGTH) 17 | } 18 | } 19 | 20 | mode == 1 && /.*\\$/ { 21 | sources=sources substr($0, 0, length - 1) 22 | next 23 | } 24 | 25 | mode == 1 { 26 | sources=sources $0 27 | mode=0 28 | } 29 | 30 | END { 31 | print sources 32 | } 33 | -------------------------------------------------------------------------------- /ext/build/ltversion.m4: -------------------------------------------------------------------------------- 1 | # ltversion.m4 -- version numbers -*- Autoconf -*- 2 | # 3 | # Copyright (C) 2004 Free Software Foundation, Inc. 4 | # Written by Scott James Remnant, 2004 5 | # 6 | # This file is free software; the Free Software Foundation gives 7 | # unlimited permission to copy and/or distribute it, with or without 8 | # modifications, as long as this notice is preserved. 9 | 10 | # @configure_input@ 11 | 12 | # serial 3337 ltversion.m4 13 | # This file is part of GNU Libtool 14 | 15 | m4_define([LT_PACKAGE_VERSION], [2.4.2]) 16 | m4_define([LT_PACKAGE_REVISION], [1.3337]) 17 | 18 | AC_DEFUN([LTVERSION_VERSION], 19 | [macro_version='2.4.2' 20 | macro_revision='1.3337' 21 | _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) 22 | _LT_DECL(, macro_revision, 0) 23 | ]) 24 | -------------------------------------------------------------------------------- /ext/kernel/concat.h: -------------------------------------------------------------------------------- 1 | #define ZEPHIR_CONCAT_SV(result, op1, op2) \ 2 | zephir_concat_sv(&result, op1, sizeof(op1)-1, op2, 0 TSRMLS_CC); 3 | #define ZEPHIR_SCONCAT_SV(result, op1, op2) \ 4 | zephir_concat_sv(&result, op1, sizeof(op1)-1, op2, 1 TSRMLS_CC); 5 | 6 | #define ZEPHIR_CONCAT_VS(result, op1, op2) \ 7 | zephir_concat_vs(&result, op1, op2, sizeof(op2)-1, 0 TSRMLS_CC); 8 | #define ZEPHIR_SCONCAT_VS(result, op1, op2) \ 9 | zephir_concat_vs(&result, op1, op2, sizeof(op2)-1, 1 TSRMLS_CC); 10 | 11 | #define ZEPHIR_CONCAT_VV(result, op1, op2) \ 12 | zephir_concat_vv(&result, op1, op2, 0 TSRMLS_CC); 13 | #define ZEPHIR_SCONCAT_VV(result, op1, op2) \ 14 | zephir_concat_vv(&result, op1, op2, 1 TSRMLS_CC); 15 | 16 | 17 | void zephir_concat_sv(zval **result, const char *op1, zend_uint op1_len, zval *op2, int self_var TSRMLS_DC); 18 | void zephir_concat_vs(zval **result, zval *op1, const char *op2, zend_uint op2_len, int self_var TSRMLS_DC); 19 | void zephir_concat_vv(zval **result, zval *op1, zval *op2, int self_var TSRMLS_DC); 20 | void zephir_concat_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); -------------------------------------------------------------------------------- /ext/jalali.la: -------------------------------------------------------------------------------- 1 | # jalali.la - a libtool library file 2 | # Generated by libtool (GNU libtool) 2.4.2 Debian-2.4.2-1.7ubuntu1 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # The name that we can dlopen(3). 8 | dlname='jalali.so' 9 | 10 | # Names of this library. 11 | library_names='jalali.so jalali.so jalali.so' 12 | 13 | # The name of the static archive. 14 | old_library='' 15 | 16 | # Linker flags that can not go in dependency_libs. 17 | inherited_linker_flags='' 18 | 19 | # Libraries that this one depends upon. 20 | dependency_libs='' 21 | 22 | # Names of additional weak libraries provided by this library 23 | weak_library_names='' 24 | 25 | # Version information for jalali. 26 | current=0 27 | age=0 28 | revision=0 29 | 30 | # Is this an already installed library? 31 | installed=no 32 | 33 | # Should we warn about portability when linking against -modules? 34 | shouldnotlink=yes 35 | 36 | # Files to dlopen/dlpreopen 37 | dlopen='' 38 | dlpreopen='' 39 | 40 | # Directory that this library needs to be installed in: 41 | libdir='/home/mohamad/projects/phpjalali/ext/modules' 42 | -------------------------------------------------------------------------------- /ext/.libs/jalali.lai: -------------------------------------------------------------------------------- 1 | # jalali.la - a libtool library file 2 | # Generated by libtool (GNU libtool) 2.4.2 Debian-2.4.2-1.7ubuntu1 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # The name that we can dlopen(3). 8 | dlname='jalali.so' 9 | 10 | # Names of this library. 11 | library_names='jalali.so jalali.so jalali.so' 12 | 13 | # The name of the static archive. 14 | old_library='' 15 | 16 | # Linker flags that can not go in dependency_libs. 17 | inherited_linker_flags='' 18 | 19 | # Libraries that this one depends upon. 20 | dependency_libs='' 21 | 22 | # Names of additional weak libraries provided by this library 23 | weak_library_names='' 24 | 25 | # Version information for jalali. 26 | current=0 27 | age=0 28 | revision=0 29 | 30 | # Is this an already installed library? 31 | installed=yes 32 | 33 | # Should we warn about portability when linking against -modules? 34 | shouldnotlink=yes 35 | 36 | # Files to dlopen/dlpreopen 37 | dlopen='' 38 | dlpreopen='' 39 | 40 | # Directory that this library needs to be installed in: 41 | libdir='/home/mohamad/projects/phpjalali/ext/modules' 42 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Mohamad Mohebifar 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /ext/kernel/extended/array.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | +------------------------------------------------------------------------+ 4 | | Zephir Language | 5 | +------------------------------------------------------------------------+ 6 | | Copyright (c) 2011-2014 Zephir Team (http://www.zephir-lang.com) | 7 | +------------------------------------------------------------------------+ 8 | | This source file is subject to the New BSD License that is bundled | 9 | | with this package in the file docs/LICENSE.txt. | 10 | | | 11 | | If you did not receive a copy of the license and are unable to | 12 | | obtain it through the world-wide-web, please send an email | 13 | | to license@zephir-lang.com so we can send you a copy immediately. | 14 | +------------------------------------------------------------------------+ 15 | | Authors: Andres Gutierrez | 16 | | Eduar Carvajal | 17 | +------------------------------------------------------------------------+ 18 | */ 19 | -------------------------------------------------------------------------------- /ext/kernel/extended/array.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | +------------------------------------------------------------------------+ 4 | | Zephir Language | 5 | +------------------------------------------------------------------------+ 6 | | Copyright (c) 2011-2014 Zephir Team (http://www.zephir-lang.com) | 7 | +------------------------------------------------------------------------+ 8 | | This source file is subject to the New BSD License that is bundled | 9 | | with this package in the file docs/LICENSE.txt. | 10 | | | 11 | | If you did not receive a copy of the license and are unable to | 12 | | obtain it through the world-wide-web, please send an email | 13 | | to license@zephir-lang.com so we can send you a copy immediately. | 14 | +------------------------------------------------------------------------+ 15 | | Authors: Andres Gutierrez | 16 | | Eduar Carvajal | 17 | +------------------------------------------------------------------------+ 18 | */ 19 | -------------------------------------------------------------------------------- /ext/kernel/exit.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | +------------------------------------------------------------------------+ 4 | | Zephir Language | 5 | +------------------------------------------------------------------------+ 6 | | Copyright (c) 2011-2014 Zephir Team (http://www.zephir-lang.com) | 7 | +------------------------------------------------------------------------+ 8 | | This source file is subject to the New BSD License that is bundled | 9 | | with this package in the file docs/LICENSE.txt. | 10 | | | 11 | | If you did not receive a copy of the license and are unable to | 12 | | obtain it through the world-wide-web, please send an email | 13 | | to license@zephir-lang.com so we can send you a copy immediately. | 14 | +------------------------------------------------------------------------+ 15 | | Authors: Song Yeung | 16 | +------------------------------------------------------------------------+ 17 | */ 18 | 19 | #ifndef ZEPHIR_KERNEL_EXIT_H 20 | #define ZEPHIR_KERNEL_EXIT_H 21 | 22 | #include 23 | 24 | void zephir_exit_empty(); 25 | void zephir_exit(zval *ptr); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /ext/kernel/persistent.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | +------------------------------------------------------------------------+ 4 | | Zephir Language | 5 | +------------------------------------------------------------------------+ 6 | | Copyright (c) 2011-2014 Zephir Team (http://www.zephir-lang.com) | 7 | +------------------------------------------------------------------------+ 8 | | This source file is subject to the New BSD License that is bundled | 9 | | with this package in the file docs/LICENSE.txt. | 10 | | | 11 | | If you did not receive a copy of the license and are unable to | 12 | | obtain it through the world-wide-web, please send an email | 13 | | to license@zephir-lang.com so we can send you a copy immediately. | 14 | +------------------------------------------------------------------------+ 15 | | Authors: Andres Gutierrez | 16 | | Eduar Carvajal | 17 | +------------------------------------------------------------------------+ 18 | */ 19 | 20 | int zephir_persistent_store(zval *service, zval *object TSRMLS_DC); 21 | int zephir_persistent_fetch(zval *return_value, zval *service TSRMLS_DC); 22 | -------------------------------------------------------------------------------- /ext/kernel/iterator.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | +------------------------------------------------------------------------+ 4 | | Zephir Language | 5 | +------------------------------------------------------------------------+ 6 | | Copyright (c) 2011-2014 Zephir Team (http://www.zephir-lang.com) | 7 | +------------------------------------------------------------------------+ 8 | | This source file is subject to the New BSD License that is bundled | 9 | | with this package in the file docs/LICENSE.txt. | 10 | | | 11 | | If you did not receive a copy of the license and are unable to | 12 | | obtain it through the world-wide-web, please send an email | 13 | | to license@zephir-lang.com so we can send you a copy immediately. | 14 | +------------------------------------------------------------------------+ 15 | | Authors: Andres Gutierrez | 16 | | Eduar Carvajal | 17 | | Vladimir Kolesnikov | 18 | +------------------------------------------------------------------------+ 19 | */ 20 | 21 | #ifndef ZEPHIR_KERNEL_ITERATOR_H 22 | #define ZEPHIR_KERNEL_ITERATOR_H 23 | 24 | zend_object_iterator *zephir_get_iterator(zval *iterator TSRMLS_DC); 25 | 26 | #endif -------------------------------------------------------------------------------- /ext/kernel/assert.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | +------------------------------------------------------------------------+ 4 | | Zephir Language | 5 | +------------------------------------------------------------------------+ 6 | | Copyright (c) 2011-2014 Zephir Team (http://www.zephir-lang.com) | 7 | +------------------------------------------------------------------------+ 8 | | This source file is subject to the New BSD License that is bundled | 9 | | with this package in the file docs/LICENSE.txt. | 10 | | | 11 | | If you did not receive a copy of the license and are unable to | 12 | | obtain it through the world-wide-web, please send an email | 13 | | to license@zephir-lang.com so we can send you a copy immediately. | 14 | +------------------------------------------------------------------------+ 15 | | Authors: Andres Gutierrez | 16 | | Eduar Carvajal | 17 | +------------------------------------------------------------------------+ 18 | */ 19 | 20 | #ifndef ZEPHIR_KERNEL_ASSERT_H 21 | #define ZEPHIR_KERNEL_ASSERT_H 22 | 23 | #ifndef ZEPHIR_RELEASE 24 | 25 | extern int zephir_assert_class(zval *object, char *class_name TSRMLS_DC); 26 | 27 | #endif 28 | #endif /* ZEPHIR_KERNEL_ASSERT_H */ -------------------------------------------------------------------------------- /ext/config.m4: -------------------------------------------------------------------------------- 1 | PHP_ARG_ENABLE(jalali, whether to enable jalali, [ --enable-jalali Enable Jalali]) 2 | 3 | if test "$PHP_JALALI" = "yes"; then 4 | AC_DEFINE(HAVE_JALALI, 1, [Whether you have Jalali]) 5 | jalali_sources="jalali.c kernel/main.c kernel/memory.c kernel/exception.c kernel/hash.c kernel/debug.c kernel/backtrace.c kernel/object.c kernel/array.c kernel/extended/array.c kernel/string.c kernel/fcall.c kernel/require.c kernel/file.c kernel/operators.c kernel/concat.c kernel/variables.c kernel/filter.c kernel/iterator.c kernel/exit.c jalali/date.zep.c " 6 | PHP_NEW_EXTENSION(jalali, $jalali_sources, $ext_shared) 7 | 8 | old_CPPFLAGS=$CPPFLAGS 9 | CPPFLAGS="$CPPFLAGS $INCLUDES" 10 | 11 | AC_CHECK_DECL( 12 | [HAVE_BUNDLED_PCRE], 13 | [ 14 | AC_CHECK_HEADERS( 15 | [ext/pcre/php_pcre.h], 16 | [ 17 | PHP_ADD_EXTENSION_DEP([jalali], [pcre]) 18 | AC_DEFINE([ZEPHIR_USE_PHP_PCRE], [1], [Whether PHP pcre extension is present at compile time]) 19 | ], 20 | , 21 | [[#include "main/php.h"]] 22 | ) 23 | ], 24 | , 25 | [[#include "php_config.h"]] 26 | ) 27 | 28 | AC_CHECK_DECL( 29 | [HAVE_JSON], 30 | [ 31 | AC_CHECK_HEADERS( 32 | [ext/json/php_json.h], 33 | [ 34 | PHP_ADD_EXTENSION_DEP([jalali], [json]) 35 | AC_DEFINE([ZEPHIR_USE_PHP_JSON], [1], [Whether PHP json extension is present at compile time]) 36 | ], 37 | , 38 | [[#include "main/php.h"]] 39 | ) 40 | ], 41 | , 42 | [[#include "php_config.h"]] 43 | ) 44 | 45 | CPPFLAGS=$old_CPPFLAGS 46 | fi 47 | -------------------------------------------------------------------------------- /ext/kernel/README.md: -------------------------------------------------------------------------------- 1 | Zephir Kernel 2 | ============== 3 | 4 | Zephir Kernel is a meta-framework on top of the Zend API helping to create PHP extensions in an easier way 5 | for a PHP developer. 6 | 7 | In order to build a fast and stable framework, we have created the Zephir Kernel. The use of 8 | this API helps us to write C code in a PHP style. We have developed a number of functions to help the 9 | programmer to write code more interoperable with PHP in a easier way. 10 | 11 | Zephir Kernel API is based on the Zend API, but we have added more features to facilitate us the work. 12 | Zephir is a very large project, frameworks need to be developed and improved every day, Zephir Kernel API 13 | helps us to write C code that is more stable and familiar to PHP developers. 14 | 15 | If you’re a PHP developer maybe you don’t know C or you don’t want to learn C, but after read this guide 16 | you will find the Zephir API very familiar to your knowledge. 17 | 18 | Zephir Kernel provides you: 19 | 20 | * Manipulate arrays/objects 21 | * Call functions/methods in the PHP userland 22 | * Automatic memory management 23 | * Require and execute PHP plain files 24 | * Simplification of common operations like concatenation 25 | * Read superglobals and update the active symbol table 26 | * Register classes in namespaces 27 | * Throw exceptions 28 | * And more 29 | 30 | License 31 | ------- 32 | Zephir is open-sourced software licensed under the New BSD License. See the LICENSE file for more information. 33 | 34 | Related Documentation 35 | --------------------- 36 | * http://internals.phalconphp.com/en/latest/index.html -------------------------------------------------------------------------------- /config.json: -------------------------------------------------------------------------------- 1 | { 2 | "stubs": { 3 | "path": "ide\/%version%\/%namespace%\/", 4 | "stubs-run-after-generate": false 5 | }, 6 | "warnings": { 7 | "unused-variable": true, 8 | "unused-variable-external": false, 9 | "possible-wrong-parameter-undefined": false, 10 | "nonexistent-function": true, 11 | "nonexistent-class": true, 12 | "non-valid-isset": true, 13 | "non-array-update": true, 14 | "non-valid-objectupdate": true, 15 | "non-valid-fetch": true, 16 | "invalid-array-index": true, 17 | "non-array-append": true, 18 | "invalid-return-type": true, 19 | "unreachable-code": true, 20 | "nonexistent-constant": true, 21 | "not-supported-magic-constant": true, 22 | "non-valid-decrement": true, 23 | "non-valid-increment": true, 24 | "non-valid-clone": true, 25 | "non-valid-new": true, 26 | "non-array-access": true, 27 | "invalid-reference": true, 28 | "invalid-typeof-comparison": true, 29 | "conditional-initialization": true 30 | }, 31 | "optimizations": { 32 | "static-type-inference": true, 33 | "static-type-inference-second-pass": true, 34 | "local-context-pass": true, 35 | "constant-folding": true, 36 | "static-constant-class-folding": true, 37 | "call-gatherer-pass": true, 38 | "check-invalid-reads": false 39 | }, 40 | "namespace": "jalali", 41 | "name": "phpjalali", 42 | "description": "", 43 | "author": "", 44 | "version": "0.0.1", 45 | "verbose": false 46 | } 47 | -------------------------------------------------------------------------------- /ext/kernel/backtrace.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | +------------------------------------------------------------------------+ 4 | | Zephir Language | 5 | +------------------------------------------------------------------------+ 6 | | Copyright (c) 2011-2014 Zephir Team (http://www.zephir-lang.com) | 7 | +------------------------------------------------------------------------+ 8 | | This source file is subject to the New BSD License that is bundled | 9 | | with this package in the file docs/LICENSE.txt. | 10 | | | 11 | | If you did not receive a copy of the license and are unable to | 12 | | obtain it through the world-wide-web, please send an email | 13 | | to license@zephir-lang.com so we can send you a copy immediately. | 14 | +------------------------------------------------------------------------+ 15 | | Authors: Andres Gutierrez | 16 | | Eduar Carvajal | 17 | | Vladimir Kolesnikov | 18 | +------------------------------------------------------------------------+ 19 | */ 20 | 21 | #ifndef ZEPHIR_KERNEL_BACKTRACE_H 22 | #define ZEPHIR_KERNEL_BACKTRACE_H 23 | 24 | #ifndef ZEPHIR_RELEASE 25 | 26 | extern void zephir_print_backtrace(void); 27 | 28 | #else 29 | 30 | #ifndef zephir_print_backtrace 31 | #define zephir_print_backtrace() 32 | #endif 33 | 34 | #endif 35 | #endif /* ZEPHIR_KERNEL_BACKTRACE_H */ -------------------------------------------------------------------------------- /ext/kernel/variables.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | +------------------------------------------------------------------------+ 4 | | Zephir Language | 5 | +------------------------------------------------------------------------+ 6 | | Copyright (c) 2011-2014 Zephir Team (http://www.zephir-lang.com) | 7 | +------------------------------------------------------------------------+ 8 | | This source file is subject to the New BSD License that is bundled | 9 | | with this package in the file docs/LICENSE.txt. | 10 | | | 11 | | If you did not receive a copy of the license and are unable to | 12 | | obtain it through the world-wide-web, please send an email | 13 | | to license@zephir-lang.com so we can send you a copy immediately. | 14 | +------------------------------------------------------------------------+ 15 | | Authors: Andres Gutierrez | 16 | | Eduar Carvajal | 17 | | Rack Lin | 18 | +------------------------------------------------------------------------+ 19 | */ 20 | 21 | void zephir_serialize(zval *return_value, zval **var TSRMLS_DC); 22 | void zephir_unserialize(zval *return_value, zval *var TSRMLS_DC); 23 | 24 | void zephir_var_export(zval **var TSRMLS_DC); 25 | void zephir_var_export_ex(zval *return_value, zval **var TSRMLS_DC); 26 | 27 | void zephir_var_dump(zval **var TSRMLS_DC); 28 | -------------------------------------------------------------------------------- /ext/kernel/session.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | +------------------------------------------------------------------------+ 4 | | Zephir Language | 5 | +------------------------------------------------------------------------+ 6 | | Copyright (c) 2011-2014 Zephir Team (http://www.zephir-lang.com) | 7 | +------------------------------------------------------------------------+ 8 | | This source file is subject to the New BSD License that is bundled | 9 | | with this package in the file docs/LICENSE.txt. | 10 | | | 11 | | If you did not receive a copy of the license and are unable to | 12 | | obtain it through the world-wide-web, please send an email | 13 | | to license@zephir-lang.com so we can send you a copy immediately. | 14 | +------------------------------------------------------------------------+ 15 | | Authors: Andres Gutierrez | 16 | | Eduar Carvajal | 17 | | Vladimir Kolesnikov | 18 | +------------------------------------------------------------------------+ 19 | */ 20 | 21 | #ifndef ZEPHIR_KERNEL_SESSION_H 22 | #define ZEPHIR_KERNEL_SESSION_H 23 | 24 | void zephir_session_start(TSRMLS_D); 25 | void zephir_session_destroy(TSRMLS_D); 26 | void zephir_get_session_id(zval *return_value, zval **return_value_ptr TSRMLS_DC); 27 | void zephir_set_session_id(zval *sid TSRMLS_DC); 28 | 29 | #endif /* ZEPHIR_KERNEL_SESSION_H */ 30 | -------------------------------------------------------------------------------- /ext/kernel/exit.c: -------------------------------------------------------------------------------- 1 | /* 2 | +------------------------------------------------------------------------+ 3 | | Zephir Language | 4 | +------------------------------------------------------------------------+ 5 | | Copyright (c) 2011-2014 Zephir Team (http://www.zephir-lang.com) | 6 | +------------------------------------------------------------------------+ 7 | | This source file is subject to the New BSD License that is bundled | 8 | | with this package in the file docs/LICENSE.txt. | 9 | | | 10 | | If you did not receive a copy of the license and are unable to | 11 | | obtain it through the world-wide-web, please send an email | 12 | | to license@zephir-lang.com so we can send you a copy immediately. | 13 | +------------------------------------------------------------------------+ 14 | | Authors: Song Yeung | 15 | +------------------------------------------------------------------------+ 16 | */ 17 | 18 | #ifdef HAVE_CONFIG_H 19 | #include "config.h" 20 | #endif 21 | 22 | #include "php.h" 23 | #include "php_ext.h" 24 | #include "php_main.h" 25 | 26 | #include "kernel/main.h" 27 | #include "kernel/exit.h" 28 | 29 | void zephir_exit_empty() { 30 | TSRMLS_FETCH(); 31 | zend_bailout(); 32 | } 33 | 34 | void zephir_exit(zval *ptr) { 35 | TSRMLS_FETCH(); 36 | if (Z_TYPE_P(ptr) == IS_LONG) { 37 | EG(exit_status) = Z_LVAL_P(ptr); 38 | } else { 39 | zend_print_variable(ptr); 40 | } 41 | zephir_exit_empty(); 42 | } 43 | -------------------------------------------------------------------------------- /ext/kernel/output.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | +------------------------------------------------------------------------+ 4 | | Zephir Language | 5 | +------------------------------------------------------------------------+ 6 | | Copyright (c) 2011-2014 Zephir Team (http://www.zephir-lang.com) | 7 | +------------------------------------------------------------------------+ 8 | | This source file is subject to the New BSD License that is bundled | 9 | | with this package in the file docs/LICENSE.txt. | 10 | | | 11 | | If you did not receive a copy of the license and are unable to | 12 | | obtain it through the world-wide-web, please send an email | 13 | | to license@zephir-lang.com so we can send you a copy immediately. | 14 | +------------------------------------------------------------------------+ 15 | | Authors: Andres Gutierrez | 16 | | Eduar Carvajal | 17 | | Vladimir Kolesnikov | 18 | +------------------------------------------------------------------------+ 19 | */ 20 | 21 | #ifndef ZEPHIR_KERNEL_OUTPUT_H 22 | #define ZEPHIR_KERNEL_OUTPUT_H 23 | 24 | void zephir_ob_start(TSRMLS_D); 25 | void zephir_ob_get_contents(zval *result TSRMLS_DC); 26 | int zephir_ob_end_flush(TSRMLS_D); 27 | int zephir_ob_end_clean(TSRMLS_D); 28 | int zephir_ob_flush(TSRMLS_D); 29 | int zephir_ob_clean(TSRMLS_D); 30 | int zephir_ob_get_level(TSRMLS_D); 31 | 32 | #endif -------------------------------------------------------------------------------- /ext/kernel/filter.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | +------------------------------------------------------------------------+ 4 | | Zephir Language | 5 | +------------------------------------------------------------------------+ 6 | | Copyright (c) 2011-2014 Zephir Team (http://www.zephir-lang.com) | 7 | +------------------------------------------------------------------------+ 8 | | This source file is subject to the New BSD License that is bundled | 9 | | with this package in the file docs/LICENSE.txt. | 10 | | | 11 | | If you did not receive a copy of the license and are unable to | 12 | | obtain it through the world-wide-web, please send an email | 13 | | to license@zephir-lang.com so we can send you a copy immediately. | 14 | +------------------------------------------------------------------------+ 15 | | Authors: Andres Gutierrez | 16 | | Eduar Carvajal | 17 | +------------------------------------------------------------------------+ 18 | */ 19 | 20 | /** Low level filters */ 21 | void zephir_filter_alphanum(zval *return_value, zval *param); 22 | void zephir_filter_identifier(zval *return_value, zval *param); 23 | 24 | /** Encoding */ 25 | void zephir_is_basic_charset(zval *return_value, const zval *param); 26 | 27 | /** Escaping */ 28 | void zephir_escape_css(zval *return_value, zval *param); 29 | void zephir_escape_js(zval *return_value, zval *param); 30 | void zephir_escape_htmlattr(zval *return_value, zval *param); 31 | void zephir_escape_html(zval *return_value, zval *str, zval *quote_style, zval *charset TSRMLS_DC); -------------------------------------------------------------------------------- /ext/php_jalali.h: -------------------------------------------------------------------------------- 1 | 2 | /* This file was generated automatically by Zephir do not modify it! */ 3 | 4 | #ifndef PHP_JALALI_H 5 | #define PHP_JALALI_H 1 6 | 7 | #define ZEPHIR_RELEASE 1 8 | 9 | #include "kernel/globals.h" 10 | 11 | #define PHP_JALALI_NAME "phpjalali" 12 | #define PHP_JALALI_VERSION "0.0.1" 13 | #define PHP_JALALI_EXTNAME "jalali" 14 | #define PHP_JALALI_AUTHOR "" 15 | #define PHP_JALALI_ZEPVERSION "0.5.2a" 16 | #define PHP_JALALI_DESCRIPTION "" 17 | 18 | 19 | 20 | ZEND_BEGIN_MODULE_GLOBALS(jalali) 21 | 22 | /* Memory */ 23 | zephir_memory_entry *start_memory; /**< The first preallocated frame */ 24 | zephir_memory_entry *end_memory; /**< The last preallocate frame */ 25 | zephir_memory_entry *active_memory; /**< The current memory frame */ 26 | 27 | /* Virtual Symbol Tables */ 28 | zephir_symbol_table *active_symbol_table; 29 | 30 | /** Function cache */ 31 | HashTable *fcache; 32 | 33 | /* Max recursion control */ 34 | unsigned int recursive_lock; 35 | 36 | /* Global constants */ 37 | zval *global_true; 38 | zval *global_false; 39 | zval *global_null; 40 | 41 | ZEND_END_MODULE_GLOBALS(jalali) 42 | 43 | #ifdef ZTS 44 | #include "TSRM.h" 45 | #endif 46 | 47 | ZEND_EXTERN_MODULE_GLOBALS(jalali) 48 | 49 | #ifdef ZTS 50 | #define ZEPHIR_GLOBAL(v) TSRMG(jalali_globals_id, zend_jalali_globals *, v) 51 | #else 52 | #define ZEPHIR_GLOBAL(v) (jalali_globals.v) 53 | #endif 54 | 55 | #ifdef ZTS 56 | #define ZEPHIR_VGLOBAL ((zend_jalali_globals *) (*((void ***) tsrm_ls))[TSRM_UNSHUFFLE_RSRC_ID(jalali_globals_id)]) 57 | #else 58 | #define ZEPHIR_VGLOBAL &(jalali_globals) 59 | #endif 60 | 61 | #define zephir_globals_def jalali_globals 62 | #define zend_zephir_globals_def zend_jalali_globals 63 | 64 | extern zend_module_entry jalali_module_entry; 65 | #define phpext_jalali_ptr &jalali_module_entry 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /ext/kernel/assert.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | +------------------------------------------------------------------------+ 4 | | Zephir Language | 5 | +------------------------------------------------------------------------+ 6 | | Copyright (c) 2011-2014 Zephir Team (http://www.zephir-lang.com) | 7 | +------------------------------------------------------------------------+ 8 | | This source file is subject to the New BSD License that is bundled | 9 | | with this package in the file docs/LICENSE.txt. | 10 | | | 11 | | If you did not receive a copy of the license and are unable to | 12 | | obtain it through the world-wide-web, please send an email | 13 | | to license@zephir-lang.com so we can send you a copy immediately. | 14 | +------------------------------------------------------------------------+ 15 | | Authors: Andres Gutierrez | 16 | | Eduar Carvajal | 17 | +------------------------------------------------------------------------+ 18 | */ 19 | 20 | #ifdef HAVE_CONFIG_H 21 | #include "config.h" 22 | #endif 23 | 24 | #include 25 | #include "php_ext.h" 26 | #include "kernel/debug.h" 27 | 28 | #ifndef ZEPHIR_RELEASE 29 | 30 | int zephir_assert_class(zval *object, char *class_name TSRMLS_DC) { 31 | if (object) { 32 | if (Z_TYPE_P(object) != IS_OBJECT) { 33 | zephir_error_space(); 34 | fprintf(zephir_log, "AssertClass: [Failed] Value is not an object\n"); 35 | return FAILURE; 36 | } else { 37 | if (strcmp(Z_OBJCE_P(object)->name, class_name)) { 38 | zephir_error_space(); 39 | fprintf(zephir_log, "AssertClass: [Failed] Object is not class %s, is %s\n", class_name, Z_OBJCE_P(object)->name); 40 | return FAILURE; 41 | } 42 | } 43 | } 44 | return SUCCESS; 45 | } 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /ext/kernel/iterator.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | +------------------------------------------------------------------------+ 4 | | Zephir Language | 5 | +------------------------------------------------------------------------+ 6 | | Copyright (c) 2011-2014 Zephir Team (http://www.zephir-lang.com) | 7 | +------------------------------------------------------------------------+ 8 | | This source file is subject to the New BSD License that is bundled | 9 | | with this package in the file docs/LICENSE.txt. | 10 | | | 11 | | If you did not receive a copy of the license and are unable to | 12 | | obtain it through the world-wide-web, please send an email | 13 | | to license@zephir-lang.com so we can send you a copy immediately. | 14 | +------------------------------------------------------------------------+ 15 | | Authors: Andres Gutierrez | 16 | | Eduar Carvajal | 17 | | Vladimir Kolesnikov | 18 | +------------------------------------------------------------------------+ 19 | */ 20 | 21 | #ifdef HAVE_CONFIG_H 22 | #include "config.h" 23 | #endif 24 | 25 | #include "php.h" 26 | 27 | #ifdef PHP_WIN32 28 | #include "php_string.h" 29 | #endif 30 | 31 | #include "php_ext.h" 32 | 33 | #include "kernel/main.h" 34 | #include "kernel/memory.h" 35 | 36 | /** 37 | * Returns an iterator from the object 38 | */ 39 | zend_object_iterator *zephir_get_iterator(zval *iterator TSRMLS_DC) { 40 | 41 | zend_class_entry *ce; 42 | zend_object_iterator *it; 43 | 44 | if (Z_TYPE_P(iterator) != IS_OBJECT) { 45 | return NULL; 46 | } 47 | 48 | ce = Z_OBJCE_P(iterator); 49 | it = ce->get_iterator(ce, iterator, 0 TSRMLS_CC); 50 | if (!it || EG(exception)) { 51 | return NULL; 52 | } 53 | 54 | if (it->funcs->get_current_key == NULL) { 55 | return NULL; 56 | } 57 | 58 | if (it->funcs->rewind == NULL) { 59 | return NULL; 60 | } 61 | 62 | return it; 63 | } -------------------------------------------------------------------------------- /ext/kernel/require.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | +------------------------------------------------------------------------+ 4 | | Zephir Language | 5 | +------------------------------------------------------------------------+ 6 | | Copyright (c) 2011-2014 Zephir Team (http://www.zephir-lang.com) | 7 | +------------------------------------------------------------------------+ 8 | | This source file is subject to the New BSD License that is bundled | 9 | | with this package in the file docs/LICENSE.txt. | 10 | | | 11 | | If you did not receive a copy of the license and are unable to | 12 | | obtain it through the world-wide-web, please send an email | 13 | | to license@zephir-lang.com so we can send you a copy immediately. | 14 | +------------------------------------------------------------------------+ 15 | | Authors: Andres Gutierrez | 16 | | Eduar Carvajal | 17 | | Vladimir Kolesnikov | 18 | +------------------------------------------------------------------------+ 19 | */ 20 | 21 | #ifndef ZEPHIR_KERNEL_REQUIRE_H 22 | #define ZEPHIR_KERNEL_REQUIRE_H 23 | 24 | #include "php_ext.h" 25 | 26 | int zephir_require_ret(zval **return_value_ptr, const char *require_path TSRMLS_DC) ZEPHIR_ATTR_NONNULL1(2); 27 | 28 | ZEPHIR_ATTR_NONNULL static inline int zephir_require(const char *require_path TSRMLS_DC) 29 | { 30 | return zephir_require_ret(NULL, require_path TSRMLS_CC); 31 | } 32 | 33 | ZEPHIR_ATTR_NONNULL static inline int zephir_require_zval(const zval *require_path TSRMLS_DC) 34 | { 35 | return zephir_require_ret(NULL, Z_TYPE_P(require_path) == IS_STRING ? Z_STRVAL_P(require_path) : "" TSRMLS_CC); 36 | } 37 | 38 | ZEPHIR_ATTR_NONNULL static inline int zephir_require_zval_ret(zval **return_value_ptr, const zval *require_path TSRMLS_DC) 39 | { 40 | return zephir_require_ret(return_value_ptr, Z_TYPE_P(require_path) == IS_STRING ? Z_STRVAL_P(require_path) : "" TSRMLS_CC); 41 | } 42 | 43 | #endif /* ZEPHIR_KERNEL_REQUIRE_H */ -------------------------------------------------------------------------------- /ext/kernel/persistent.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | +------------------------------------------------------------------------+ 4 | | Zephir Language | 5 | +------------------------------------------------------------------------+ 6 | | Copyright (c) 2011-2014 Zephir Team (http://www.zephir-lang.com) | 7 | +------------------------------------------------------------------------+ 8 | | This source file is subject to the New BSD License that is bundled | 9 | | with this package in the file docs/LICENSE.txt. | 10 | | | 11 | | If you did not receive a copy of the license and are unable to | 12 | | obtain it through the world-wide-web, please send an email | 13 | | to license@zephir-lang.com so we can send you a copy immediately. | 14 | +------------------------------------------------------------------------+ 15 | | Authors: Andres Gutierrez | 16 | | Eduar Carvajal | 17 | +------------------------------------------------------------------------+ 18 | */ 19 | 20 | #ifdef HAVE_CONFIG_H 21 | #include "config.h" 22 | #endif 23 | 24 | #include "php.h" 25 | #include "php_ext.h" 26 | 27 | /* represents a connection to a database */ 28 | struct _zephir_persist_obj { 29 | char *data; 30 | } zephir_persist_obj; 31 | 32 | int zephir_persistent_fetch(zval *return_value, zval *service TSRMLS_DC){ 33 | zend_rsrc_list_entry *le; 34 | 35 | /* try to find if we already have this link in our persistent list */ 36 | if (zend_hash_find(&EG(persistent_list), Z_STRVAL_P(service), Z_STRLEN_P(service)+1, (void **) &le)==FAILURE) { 37 | 38 | } 39 | } 40 | 41 | int zephir_persistent_store(zval *service, zval *object TSRMLS_DC){ 42 | 43 | //pdo_dbh_t *dbh = NULL; 44 | 45 | //zend_object_store_set_object(object, dbh TSRMLS_CC); 46 | 47 | 48 | zend_rsrc_list_entry new_le; 49 | 50 | Z_TYPE(new_le) = 1; 51 | new_le.ptr = pestrdup("hello", 1); 52 | if (zend_hash_update(&EG(persistent_list), Z_STRVAL_P(service), Z_STRLEN_P(service)+1, (void *) &new_le, sizeof(zend_rsrc_list_entry), NULL)==FAILURE) { 53 | //goto err; 54 | } 55 | 56 | //zephir_persistent_store 57 | 58 | } 59 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | PHP Jalali Extension 2 | ==================== 3 | Jalali extension is a php extension written in C which allows you to format a timestamp by *Hejri Date Format* or get the timestamp by giving *Hejri Dates*. 4 | 5 | This is simply **as fast as** `date()` and `mktime()` functions. 6 | 7 | Installation 8 | ========== 9 | Copy the `build/jalali.so` into the php extensions directory. Then add this line into the `php.ini` : 10 | 11 | extension=jalali.so 12 | 13 | Done ! 14 | 15 | ## PHP Version ## 16 | If you are running php on a windows machine when developing or **you cannot install the extension for some reason**, You can include the **php version** which exists in `php` directory. **It uses the extension if it existed** otherwise It defines the same class in php context. 17 | 18 | How to use 19 | ========= 20 | Create an object of `\Jalali\Date`. 21 | 22 | ```php 23 | $jDate = new \Jalali\Date(); 24 | ``` 25 | 26 | You can format the date by calling `$jDate::date`. The function covers all of the native `date()` function literals. 27 | 28 | ```php 29 | $jDate->date("l jS F Y"); 30 | // Output: دوشنبه بیست و یکم مهر 1393 31 | ``` 32 | 33 | And Also You can get the timestamp of a date time. 34 | 35 | ```php 36 | $jDate->mktime(15, 45, 0, 7, 21, 1393); 37 | ``` 38 | 39 | Benchmark 40 | ========= 41 | As you know calculating Hejri Date from a timestamp includes of a lot of addition, subtraction, multiplication, and division, so it increases cpu cycles. 42 | 43 | This is the fastest class ever known in php to do that ! 44 | 45 | We compare the extension with [sallar/jDateTime](https://github.com/sallar/jDateTime) so that we do the same `date("Y m d l s f")` action with both classes 100,000 times. 46 | 47 | I ran the script on an ubuntu 14.04 machine with php5.5 installed and enabled opcache. 48 | 49 | ```php 50 | $phpJDate = new jDateTime(); 51 | $extJDate = new \Jalali\Date(); 52 | 53 | $phpTime = 0; 54 | $extTime = 0; 55 | 56 | $time = time(); 57 | for($i = 0; $i < 100000; $i++) { 58 | $start = microtime(true); 59 | $phpJDate->date("Y m d l s f"); 60 | $phpTime += microtime(true) - $start; 61 | 62 | $start = microtime(true); 63 | $extJDate->date("Y m d l s f"); 64 | $extTime += microtime(true) - $start; 65 | } 66 | 67 | var_dump($phpTime, $extTime); 68 | ``` 69 | 70 | And the result is : 71 | 72 | 18.459370851517 seconds for sallar/jDateTime 73 | 5.1387049674988 seconds for mohebifar/php-jalali-extension 74 | -------------------------------------------------------------------------------- /ext/config.h.in: -------------------------------------------------------------------------------- 1 | /* config.h.in. Generated from configure.in by autoheader. */ 2 | 3 | /* Whether to build jalali as dynamic module */ 4 | #undef COMPILE_DL_JALALI 5 | 6 | /* Define to 1 if you have the header file. */ 7 | #undef HAVE_DLFCN_H 8 | 9 | /* Define to 1 if you have the header file. */ 10 | #undef HAVE_EXT_JSON_PHP_JSON_H 11 | 12 | /* Define to 1 if you have the header file. */ 13 | #undef HAVE_EXT_PCRE_PHP_PCRE_H 14 | 15 | /* Define to 1 if you have the header file. */ 16 | #undef HAVE_INTTYPES_H 17 | 18 | /* Whether you have Jalali */ 19 | #undef HAVE_JALALI 20 | 21 | /* Define to 1 if you have the header file. */ 22 | #undef HAVE_MEMORY_H 23 | 24 | /* Define to 1 if you have the header file. */ 25 | #undef HAVE_STDINT_H 26 | 27 | /* Define to 1 if you have the header file. */ 28 | #undef HAVE_STDLIB_H 29 | 30 | /* Define to 1 if you have the header file. */ 31 | #undef HAVE_STRINGS_H 32 | 33 | /* Define to 1 if you have the header file. */ 34 | #undef HAVE_STRING_H 35 | 36 | /* Define to 1 if you have the header file. */ 37 | #undef HAVE_SYS_STAT_H 38 | 39 | /* Define to 1 if you have the header file. */ 40 | #undef HAVE_SYS_TYPES_H 41 | 42 | /* Define to 1 if you have the header file. */ 43 | #undef HAVE_UNISTD_H 44 | 45 | /* Define to the sub-directory in which libtool stores uninstalled libraries. 46 | */ 47 | #undef LT_OBJDIR 48 | 49 | /* Define to 1 if your C compiler doesn't accept -c and -o together. */ 50 | #undef NO_MINUS_C_MINUS_O 51 | 52 | /* Define to the address where bug reports for this package should be sent. */ 53 | #undef PACKAGE_BUGREPORT 54 | 55 | /* Define to the full name of this package. */ 56 | #undef PACKAGE_NAME 57 | 58 | /* Define to the full name and version of this package. */ 59 | #undef PACKAGE_STRING 60 | 61 | /* Define to the one symbol short name of this package. */ 62 | #undef PACKAGE_TARNAME 63 | 64 | /* Define to the home page for this package. */ 65 | #undef PACKAGE_URL 66 | 67 | /* Define to the version of this package. */ 68 | #undef PACKAGE_VERSION 69 | 70 | /* Define to 1 if you have the ANSI C header files. */ 71 | #undef STDC_HEADERS 72 | 73 | /* Whether PHP json extension is present at compile time */ 74 | #undef ZEPHIR_USE_PHP_JSON 75 | 76 | /* Whether PHP pcre extension is present at compile time */ 77 | #undef ZEPHIR_USE_PHP_PCRE 78 | -------------------------------------------------------------------------------- /ext/kernel/backtrace.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | +------------------------------------------------------------------------+ 4 | | Zephir Language | 5 | +------------------------------------------------------------------------+ 6 | | Copyright (c) 2011-2014 Zephir Team (http://www.zephir-lang.com) | 7 | +------------------------------------------------------------------------+ 8 | | This source file is subject to the New BSD License that is bundled | 9 | | with this package in the file docs/LICENSE.txt. | 10 | | | 11 | | If you did not receive a copy of the license and are unable to | 12 | | obtain it through the world-wide-web, please send an email | 13 | | to license@zephir-lang.com so we can send you a copy immediately. | 14 | +------------------------------------------------------------------------+ 15 | | Authors: Andres Gutierrez | 16 | | Eduar Carvajal | 17 | | Vladimir Kolesnikov | 18 | +------------------------------------------------------------------------+ 19 | */ 20 | 21 | #ifndef ZEPHIR_RELEASE 22 | #if defined(linux) 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | /** 29 | * A buffer for backtrace. It is better to have it allocated statically 30 | * in order not to face out of memory conditions later 31 | */ 32 | void *backtrace_buf[4096]; 33 | 34 | void zephir_print_backtrace(void) 35 | { 36 | int i; 37 | int stack_size = backtrace(backtrace_buf, sizeof(backtrace_buf) / sizeof(void*)); 38 | char **stack_symbols = backtrace_symbols(backtrace_buf, stack_size); 39 | char buf[50]; 40 | smart_str s; 41 | 42 | s.c = NULL; 43 | 44 | for (i = 0; i < stack_size; ++i) { 45 | snprintf(buf, sizeof(buf), "#%d %p [", i, backtrace_buf[i]); 46 | smart_str_appends(&s, buf); 47 | smart_str_appends(&s, stack_symbols[i]); 48 | smart_str_appends(&s, "]\n"); 49 | } 50 | 51 | smart_str_0(&s); 52 | 53 | fprintf(stderr, "%s\n", s.c); 54 | smart_str_free(&s); 55 | } 56 | 57 | #else 58 | 59 | void zephir_print_backtrace(void) 60 | { 61 | /** 62 | * Not implemented yet for anything other than Linux 63 | */ 64 | } 65 | 66 | #endif 67 | #endif /* ZEPHIR_RELEASE */ 68 | -------------------------------------------------------------------------------- /ext/build/mkdep.awk: -------------------------------------------------------------------------------- 1 | # +----------------------------------------------------------------------+ 2 | # | PHP Version 5 | 3 | # +----------------------------------------------------------------------+ 4 | # | Copyright (c) 2000-2006 The PHP Group | 5 | # +----------------------------------------------------------------------+ 6 | # | This source file is subject to version 3.01 of the PHP license, | 7 | # | that is bundled with this package in the file LICENSE, and is | 8 | # | available through the world-wide-web at the following url: | 9 | # | http://www.php.net/license/3_01.txt | 10 | # | If you did not receive a copy of the PHP license and are unable to | 11 | # | obtain it through the world-wide-web, please send a note to | 12 | # | license@php.net so we can mail you a copy immediately. | 13 | # +----------------------------------------------------------------------+ 14 | # | Author: Sascha Schumann | 15 | # +----------------------------------------------------------------------+ 16 | # 17 | # $Id$ 18 | # 19 | # Usage: 20 | # 21 | # echo top_srcdir top_builddir srcdir CPP [CPP-ARGS] filenames | \ 22 | # awk -f mkdep.awk > dependencies 23 | 24 | 25 | { 26 | top_srcdir=$1 27 | top_builddir=$2 28 | srcdir=$3 29 | cmd=$4 30 | 31 | for (i = 5; i <= NF; i++) { 32 | if (match($i, "^-[A-Z]") == 0) 33 | break; 34 | cmd=cmd " " $i 35 | } 36 | 37 | dif=i-1 38 | 39 | for (; i <= NF; i++) 40 | filenames[i-dif]=$i 41 | 42 | no_files=NF-dif 43 | 44 | for(i = 1; i <= no_files; i++) { 45 | if (system("test -r " filenames[i]) != 0) 46 | continue 47 | 48 | target=filenames[i] 49 | sub(srcdir "/", "", target) 50 | target2=target 51 | sub("\.(c|cpp)$", ".lo", target); 52 | sub("\.(c|cpp)$", ".slo", target2); 53 | 54 | for (e in used) 55 | delete used[e] 56 | 57 | cmdx=cmd " " filenames[i] 58 | done=0 59 | while ((cmdx | getline) > 0) { 60 | if (match($0, "^# [0-9]* \".*\.h\"") != 0) { 61 | if (sub(top_srcdir, "$(top_srcdir)", $3) == 0) 62 | sub(top_builddir, "$(top_builddir)", $3) 63 | if (substr($3,2,1) != "/" && used[$3] != 1) { 64 | if (done == 0) 65 | printf(target " " target2 ":") 66 | done=1 67 | printf(" \\\n\t" substr($3,2,length($3)-2)) 68 | used[$3] = 1; 69 | } 70 | } 71 | } 72 | if (done == 1) 73 | print "\n" 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /ext/config.h: -------------------------------------------------------------------------------- 1 | /* config.h. Generated from config.h.in by configure. */ 2 | /* config.h.in. Generated from configure.in by autoheader. */ 3 | 4 | /* Whether to build jalali as dynamic module */ 5 | #define COMPILE_DL_JALALI 1 6 | 7 | /* Define to 1 if you have the header file. */ 8 | #define HAVE_DLFCN_H 1 9 | 10 | /* Define to 1 if you have the header file. */ 11 | /* #undef HAVE_EXT_JSON_PHP_JSON_H */ 12 | 13 | /* Define to 1 if you have the header file. */ 14 | /* #undef HAVE_EXT_PCRE_PHP_PCRE_H */ 15 | 16 | /* Define to 1 if you have the header file. */ 17 | #define HAVE_INTTYPES_H 1 18 | 19 | /* Whether you have Jalali */ 20 | #define HAVE_JALALI 1 21 | 22 | /* Define to 1 if you have the header file. */ 23 | #define HAVE_MEMORY_H 1 24 | 25 | /* Define to 1 if you have the header file. */ 26 | #define HAVE_STDINT_H 1 27 | 28 | /* Define to 1 if you have the header file. */ 29 | #define HAVE_STDLIB_H 1 30 | 31 | /* Define to 1 if you have the header file. */ 32 | #define HAVE_STRINGS_H 1 33 | 34 | /* Define to 1 if you have the header file. */ 35 | #define HAVE_STRING_H 1 36 | 37 | /* Define to 1 if you have the header file. */ 38 | #define HAVE_SYS_STAT_H 1 39 | 40 | /* Define to 1 if you have the header file. */ 41 | #define HAVE_SYS_TYPES_H 1 42 | 43 | /* Define to 1 if you have the header file. */ 44 | #define HAVE_UNISTD_H 1 45 | 46 | /* Define to the sub-directory in which libtool stores uninstalled libraries. 47 | */ 48 | #define LT_OBJDIR ".libs/" 49 | 50 | /* Define to 1 if your C compiler doesn't accept -c and -o together. */ 51 | /* #undef NO_MINUS_C_MINUS_O */ 52 | 53 | /* Define to the address where bug reports for this package should be sent. */ 54 | #define PACKAGE_BUGREPORT "" 55 | 56 | /* Define to the full name of this package. */ 57 | #define PACKAGE_NAME "" 58 | 59 | /* Define to the full name and version of this package. */ 60 | #define PACKAGE_STRING "" 61 | 62 | /* Define to the one symbol short name of this package. */ 63 | #define PACKAGE_TARNAME "" 64 | 65 | /* Define to the home page for this package. */ 66 | #define PACKAGE_URL "" 67 | 68 | /* Define to the version of this package. */ 69 | #define PACKAGE_VERSION "" 70 | 71 | /* Define to 1 if you have the ANSI C header files. */ 72 | #define STDC_HEADERS 1 73 | 74 | /* Whether PHP json extension is present at compile time */ 75 | /* #undef ZEPHIR_USE_PHP_JSON */ 76 | 77 | /* Whether PHP pcre extension is present at compile time */ 78 | /* #undef ZEPHIR_USE_PHP_PCRE */ 79 | -------------------------------------------------------------------------------- /ext/kernel/debug.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | +------------------------------------------------------------------------+ 4 | | Zephir Language | 5 | +------------------------------------------------------------------------+ 6 | | Copyright (c) 2011-2014 Zephir Team (http://www.zephir-lang.com) | 7 | +------------------------------------------------------------------------+ 8 | | This source file is subject to the New BSD License that is bundled | 9 | | with this package in the file docs/LICENSE.txt. | 10 | | | 11 | | If you did not receive a copy of the license and are unable to | 12 | | obtain it through the world-wide-web, please send an email | 13 | | to license@zephir-lang.com so we can send you a copy immediately. | 14 | +------------------------------------------------------------------------+ 15 | | Authors: Andres Gutierrez | 16 | | Eduar Carvajal | 17 | +------------------------------------------------------------------------+ 18 | */ 19 | 20 | #ifndef ZEPHIR_RELEASE 21 | 22 | #define PHV(v) zephir_vdump(v) 23 | #define PHPR(v) zephir_print_r(v) 24 | 25 | typedef struct _zephir_debug_entry { 26 | struct _zephir_debug_entry *prev; 27 | struct _zephir_debug_entry *next; 28 | char *class_name; 29 | char *method_name; 30 | int lineno; 31 | } zephir_debug_entry; 32 | 33 | int zephir_start_debug(); 34 | int zephir_stop_debug(); 35 | 36 | int zephir_print_r(zval *userval TSRMLS_DC); 37 | int zephir_vdump(zval *uservar TSRMLS_DC); 38 | int zephir_debug_assign(char *name, zval *value TSRMLS_DC); 39 | int zephir_vpdump(const zval **uservar TSRMLS_DC); 40 | int zephir_dump_ce(zend_class_entry *ce TSRMLS_DC); 41 | int zephir_class_debug(zval *val TSRMLS_DC); 42 | 43 | int zephir_debug_backtrace_internal(); 44 | int zephir_debug_str(char *what, char *message); 45 | int zephir_debug_long(char *what, uint vlong); 46 | int zephir_debug_screen(char *message); 47 | 48 | int zephir_step_over(char *message); 49 | int zephir_step_into(char *message); 50 | int zephir_step_out(char *message); 51 | 52 | int zephir_step_into_entry(char *class_name, char *method_name, int lineno); 53 | int zephir_step_out_entry(); 54 | 55 | int zephir_debug_method_call(zval *obj, char *method_name TSRMLS_DC); 56 | int zephir_debug_vdump(char *preffix, zval *value TSRMLS_DC); 57 | int zephir_debug_param(zval *param TSRMLS_DC); 58 | 59 | int zephir_error_space(); 60 | int zephir_debug_space(); 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /ext/kernel/file.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | +------------------------------------------------------------------------+ 4 | | Zephir Language | 5 | +------------------------------------------------------------------------+ 6 | | Copyright (c) 2011-2014 Zephir Team (http://www.zephir-lang.com) | 7 | +------------------------------------------------------------------------+ 8 | | This source file is subject to the New BSD License that is bundled | 9 | | with this package in the file docs/LICENSE.txt. | 10 | | | 11 | | If you did not receive a copy of the license and are unable to | 12 | | obtain it through the world-wide-web, please send an email | 13 | | to license@zephir-lang.com so we can send you a copy immediately. | 14 | +------------------------------------------------------------------------+ 15 | | Authors: Andres Gutierrez | 16 | | Eduar Carvajal | 17 | +------------------------------------------------------------------------+ 18 | */ 19 | 20 | #ifndef ZEPHIR_KERNEL_FILE_H 21 | #define ZEPHIR_KERNEL_FILE_H 22 | 23 | int zephir_file_exists(zval *filename TSRMLS_DC); 24 | int zephir_compare_mtime(zval *filename1, zval *filename2 TSRMLS_DC); 25 | void zephir_fix_path(zval **return_value, zval *path, zval *directory_separator TSRMLS_DC); 26 | void zephir_prepare_virtual_path(zval *return_value, zval *path, zval *virtual_separator TSRMLS_DC); 27 | void zephir_unique_path_key(zval *return_value, zval *path TSRMLS_DC); 28 | void zephir_realpath(zval *return_value, zval *filename TSRMLS_DC); 29 | void zephir_file_get_contents(zval *return_value, zval *filename TSRMLS_DC); 30 | void zephir_file_put_contents(zval *return_value, zval *filename, zval *data TSRMLS_DC); 31 | void zephir_possible_autoload_filepath(zval *return_value, zval *prefix, zval *class_name, zval *virtual_separator, zval *separator TSRMLS_DC); 32 | 33 | void zephir_is_dir(zval *return_value, zval *path TSRMLS_DC); 34 | void zephir_unlink(zval *return_value, zval *path TSRMLS_DC); 35 | void zephir_filemtime(zval *return_value, zval *path TSRMLS_DC); 36 | void zephir_basename(zval *return_value, zval *path TSRMLS_DC); 37 | 38 | void zephir_fwrite(zval *return_value, zval *stream_zval, zval *data TSRMLS_DC); 39 | int zephir_feof(zval *stream_zval TSRMLS_DC); 40 | int zephir_fclose(zval *stream_zval TSRMLS_DC); 41 | 42 | #ifdef TSRM_WIN32 43 | #define ZEPHIR_DIRECTORY_SEPARATOR "\\" 44 | #else 45 | #define ZEPHIR_DIRECTORY_SEPARATOR "/" 46 | #endif 47 | 48 | #endif /* ZEPHIR_KERNEL_FILE_H */ 49 | -------------------------------------------------------------------------------- /ext/jalali/date.zep.h: -------------------------------------------------------------------------------- 1 | 2 | extern zend_class_entry *jalali_date_ce; 3 | 4 | ZEPHIR_INIT_CLASS(Jalali_Date); 5 | 6 | PHP_METHOD(Jalali_Date, __construct); 7 | PHP_METHOD(Jalali_Date, mktime); 8 | PHP_METHOD(Jalali_Date, getJalali); 9 | PHP_METHOD(Jalali_Date, date); 10 | PHP_METHOD(Jalali_Date, dayOfWeek); 11 | PHP_METHOD(Jalali_Date, isLeap); 12 | PHP_METHOD(Jalali_Date, modulus); 13 | PHP_METHOD(Jalali_Date, getMonthName); 14 | PHP_METHOD(Jalali_Date, getDayInWeekName); 15 | PHP_METHOD(Jalali_Date, getNumberWord); 16 | 17 | ZEND_BEGIN_ARG_INFO_EX(arginfo_jalali_date_mktime, 0, 0, 6) 18 | ZEND_ARG_INFO(0, hour) 19 | ZEND_ARG_INFO(0, minute) 20 | ZEND_ARG_INFO(0, second) 21 | ZEND_ARG_INFO(0, month) 22 | ZEND_ARG_INFO(0, day) 23 | ZEND_ARG_INFO(0, year) 24 | ZEND_END_ARG_INFO() 25 | 26 | ZEND_BEGIN_ARG_INFO_EX(arginfo_jalali_date_getjalali, 0, 0, 1) 27 | ZEND_ARG_INFO(0, timestamp) 28 | ZEND_END_ARG_INFO() 29 | 30 | ZEND_BEGIN_ARG_INFO_EX(arginfo_jalali_date_date, 0, 0, 1) 31 | ZEND_ARG_INFO(0, format) 32 | ZEND_ARG_INFO(0, timestamp) 33 | ZEND_END_ARG_INFO() 34 | 35 | ZEND_BEGIN_ARG_INFO_EX(arginfo_jalali_date_dayofweek, 0, 0, 2) 36 | ZEND_ARG_INFO(0, dayOfYear) 37 | ZEND_ARG_INFO(0, year) 38 | ZEND_END_ARG_INFO() 39 | 40 | ZEND_BEGIN_ARG_INFO_EX(arginfo_jalali_date_isleap, 0, 0, 1) 41 | ZEND_ARG_INFO(0, year) 42 | ZEND_END_ARG_INFO() 43 | 44 | ZEND_BEGIN_ARG_INFO_EX(arginfo_jalali_date_modulus, 0, 0, 2) 45 | ZEND_ARG_INFO(0, a) 46 | ZEND_ARG_INFO(0, b) 47 | ZEND_END_ARG_INFO() 48 | 49 | ZEND_BEGIN_ARG_INFO_EX(arginfo_jalali_date_getmonthname, 0, 0, 1) 50 | ZEND_ARG_INFO(0, month) 51 | ZEND_ARG_INFO(0, type) 52 | ZEND_END_ARG_INFO() 53 | 54 | ZEND_BEGIN_ARG_INFO_EX(arginfo_jalali_date_getdayinweekname, 0, 0, 1) 55 | ZEND_ARG_INFO(0, day) 56 | ZEND_ARG_INFO(0, type) 57 | ZEND_END_ARG_INFO() 58 | 59 | ZEND_BEGIN_ARG_INFO_EX(arginfo_jalali_date_getnumberword, 0, 0, 1) 60 | ZEND_ARG_INFO(0, number) 61 | ZEND_END_ARG_INFO() 62 | 63 | ZEPHIR_INIT_FUNCS(jalali_date_method_entry) { 64 | PHP_ME(Jalali_Date, __construct, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) 65 | PHP_ME(Jalali_Date, mktime, arginfo_jalali_date_mktime, ZEND_ACC_PUBLIC) 66 | PHP_ME(Jalali_Date, getJalali, arginfo_jalali_date_getjalali, ZEND_ACC_PUBLIC) 67 | PHP_ME(Jalali_Date, date, arginfo_jalali_date_date, ZEND_ACC_PUBLIC) 68 | PHP_ME(Jalali_Date, dayOfWeek, arginfo_jalali_date_dayofweek, ZEND_ACC_PRIVATE) 69 | PHP_ME(Jalali_Date, isLeap, arginfo_jalali_date_isleap, ZEND_ACC_PRIVATE) 70 | PHP_ME(Jalali_Date, modulus, arginfo_jalali_date_modulus, ZEND_ACC_PRIVATE) 71 | PHP_ME(Jalali_Date, getMonthName, arginfo_jalali_date_getmonthname, ZEND_ACC_PRIVATE) 72 | PHP_ME(Jalali_Date, getDayInWeekName, arginfo_jalali_date_getdayinweekname, ZEND_ACC_PRIVATE) 73 | PHP_ME(Jalali_Date, getNumberWord, arginfo_jalali_date_getnumberword, ZEND_ACC_PRIVATE) 74 | PHP_FE_END 75 | }; 76 | -------------------------------------------------------------------------------- /ext/kernel/hash.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | +------------------------------------------------------------------------+ 4 | | Zephir Language | 5 | +------------------------------------------------------------------------+ 6 | | Copyright (c) 2011-2014 Zephir Team (http://www.zephir-lang.com) | 7 | +------------------------------------------------------------------------+ 8 | | This source file is subject to the New BSD License that is bundled | 9 | | with this package in the file docs/LICENSE.txt. | 10 | | | 11 | | If you did not receive a copy of the license and are unable to | 12 | | obtain it through the world-wide-web, please send an email | 13 | | to license@zephir-lang.com so we can send you a copy immediately. | 14 | +------------------------------------------------------------------------+ 15 | | Authors: Andres Gutierrez | 16 | | Eduar Carvajal | 17 | | Vladimir Kolesnikov | 18 | +------------------------------------------------------------------------+ 19 | */ 20 | 21 | #ifndef ZEPHIR_KERNEL_HASH_H 22 | #define ZEPHIR_KERNEL_HASH_H 23 | 24 | int zephir_hash_exists(const HashTable *ht, const char *arKey, uint nKeyLength); 25 | int zephir_hash_quick_exists(const HashTable *ht, const char *arKey, uint nKeyLength, ulong h); 26 | int zephir_hash_find(const HashTable *ht, const char *arKey, uint nKeyLength, void **pData); 27 | int zephir_hash_quick_find(const HashTable *ht, const char *arKey, uint nKeyLength, ulong h, void **pData); 28 | void zephir_get_current_key(zval **key, const HashTable *hash_table, HashPosition *hash_position TSRMLS_DC); 29 | zval zephir_get_current_key_w(const HashTable *hash_table, HashPosition *hash_position); 30 | int zephir_has_numeric_keys(const zval *data); 31 | void zephir_hash_update_or_insert(HashTable *ht, zval *offset, zval *value); 32 | zval** zephir_hash_get(HashTable *ht, zval *key, int type); 33 | int zephir_hash_unset(HashTable *ht, zval *offset); 34 | 35 | #define zephir_hash_move_forward_ex(ht, pos) *pos = (*pos ? (*pos)->pListNext : NULL) 36 | 37 | static zend_always_inline int zephir_hash_get_current_data_ex(HashTable *ht, void **pData, HashPosition *pos) 38 | { 39 | Bucket *p; 40 | p = pos ? (*pos) : ht->pInternalPointer; 41 | if (p) { 42 | *pData = p->pData; 43 | return SUCCESS; 44 | } else { 45 | return FAILURE; 46 | } 47 | } 48 | 49 | static zend_always_inline int zephir_hash_move_backwards_ex(HashTable *ht, HashPosition *pos) 50 | { 51 | HashPosition *current = pos ? pos : &ht->pInternalPointer; 52 | if (*current) { 53 | *current = (*current)->pListLast; 54 | return SUCCESS; 55 | } else { 56 | return FAILURE; 57 | } 58 | } 59 | 60 | #endif -------------------------------------------------------------------------------- /ext/kernel/session.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | +------------------------------------------------------------------------+ 4 | | Zephir Language | 5 | +------------------------------------------------------------------------+ 6 | | Copyright (c) 2011-2014 Zephir Team (http://www.zephir-lang.com) | 7 | +------------------------------------------------------------------------+ 8 | | This source file is subject to the New BSD License that is bundled | 9 | | with this package in the file docs/LICENSE.txt. | 10 | | | 11 | | If you did not receive a copy of the license and are unable to | 12 | | obtain it through the world-wide-web, please send an email | 13 | | to license@zephir-lang.com so we can send you a copy immediately. | 14 | +------------------------------------------------------------------------+ 15 | | Authors: Andres Gutierrez | 16 | | Eduar Carvajal | 17 | | Vladimir Kolesnikov | 18 | +------------------------------------------------------------------------+ 19 | */ 20 | 21 | #ifdef HAVE_CONFIG_H 22 | #include "config.h" 23 | #endif 24 | 25 | #include "php.h" 26 | #include "php_ext.h" 27 | 28 | #include "kernel/main.h" 29 | #include "kernel/fcall.h" 30 | #include "kernel/session.h" 31 | 32 | #ifdef ZEPHIR_USE_PHP_SESSION 33 | #include 34 | #endif 35 | 36 | void zephir_session_start(TSRMLS_D) 37 | { 38 | #ifdef ZEPHIR_USE_PHP_SESSION 39 | php_session_start(TSRMLS_C); 40 | #else 41 | //zephir_call_func_params(NULL, NULL, SL("session_start") TSRMLS_CC, 0); 42 | #endif 43 | } 44 | 45 | void zephir_session_destroy(TSRMLS_D) 46 | { 47 | //zephir_call_func_params(NULL, NULL, SL("session_destroy") TSRMLS_CC, 0); 48 | } 49 | 50 | void zephir_get_session_id(zval *return_value, zval **return_value_ptr TSRMLS_DC) 51 | { 52 | #ifdef ZEPHIR_USE_PHP_SESSION 53 | if (PS(id)) { 54 | RETURN_STRING(PS(id), 1); 55 | } 56 | 57 | RETURN_EMPTY_STRING(); 58 | #else 59 | //zephir_call_func_params(return_value, return_value_ptr, SL("session_id") TSRMLS_CC, 0); 60 | #endif 61 | } 62 | 63 | void zephir_set_session_id(zval *sid TSRMLS_DC) 64 | { 65 | #ifdef ZEPHIR_USE_PHP_SESSION 66 | zval copy; 67 | int use_copy = 0; 68 | 69 | if (unlikely(Z_TYPE_P(sid) != IS_STRING)) { 70 | zend_make_printable_zval(sid, ©, &use_copy); 71 | if (use_copy) { 72 | sid = © 73 | } 74 | } 75 | 76 | if (PS(id)) { 77 | efree(PS(id)); 78 | } 79 | 80 | PS(id) = estrndup(Z_STRVAL_P(sid), Z_STRLEN_P(sid)); 81 | 82 | if (unlikely(use_copy)) { 83 | zval_dtor(©); 84 | } 85 | #else 86 | //zephir_call_func_params(NULL, NULL, SL("session_id") TSRMLS_CC, 1, sid); 87 | #endif 88 | } 89 | -------------------------------------------------------------------------------- /ext/autom4te.cache/requests: -------------------------------------------------------------------------------- 1 | # This file was generated by Autom4te Thu Apr 10 10:06:43 UTC 2014. 2 | # It contains the lists of macros which have been traced. 3 | # It can be safely removed. 4 | 5 | @request = ( 6 | bless( [ 7 | '0', 8 | 1, 9 | [ 10 | '/usr/share/autoconf' 11 | ], 12 | [ 13 | '/usr/share/autoconf/autoconf/autoconf.m4f', 14 | 'aclocal.m4', 15 | 'configure.in' 16 | ], 17 | { 18 | 'm4_include' => 1, 19 | 'LT_SUPPORTED_TAG' => 1, 20 | 'AM_PROG_FC_C_O' => 1, 21 | 'AM_ENABLE_MULTILIB' => 1, 22 | '_m4_warn' => 1, 23 | '_LT_AC_TAGCONFIG' => 1, 24 | 'AC_SUBST_TRACE' => 1, 25 | 'AC_FC_SRCEXT' => 1, 26 | 'AM_PROG_F77_C_O' => 1, 27 | 'AM_GNU_GETTEXT_INTL_SUBDIR' => 1, 28 | 'AC_FC_FREEFORM' => 1, 29 | 'LT_INIT' => 1, 30 | 'AC_CANONICAL_BUILD' => 1, 31 | 'AC_DEFINE_TRACE_LITERAL' => 1, 32 | 'AM_MAINTAINER_MODE' => 1, 33 | 'AC_SUBST' => 1, 34 | 'AM_PATH_GUILE' => 1, 35 | '_AM_COND_IF' => 1, 36 | 'AM_XGETTEXT_OPTION' => 1, 37 | '_AM_MAKEFILE_INCLUDE' => 1, 38 | 'AC_CANONICAL_HOST' => 1, 39 | 'AC_CONFIG_AUX_DIR' => 1, 40 | 'LT_CONFIG_LTDL_DIR' => 1, 41 | 'AM_POT_TOOLS' => 1, 42 | 'AC_INIT' => 1, 43 | 'AM_MAKEFILE_INCLUDE' => 1, 44 | 'AM_PROG_AR' => 1, 45 | 'AM_NLS' => 1, 46 | '_AM_COND_ENDIF' => 1, 47 | 'AM_PROG_MOC' => 1, 48 | 'sinclude' => 1, 49 | 'AH_OUTPUT' => 1, 50 | 'AC_CONFIG_SUBDIRS' => 1, 51 | 'AC_PROG_LIBTOOL' => 1, 52 | '_AM_COND_ELSE' => 1, 53 | 'AC_CONFIG_FILES' => 1, 54 | 'AC_CONFIG_HEADERS' => 1, 55 | '_AM_SUBST_NOTMAKE' => 1, 56 | 'm4_sinclude' => 1, 57 | 'AC_CONFIG_LIBOBJ_DIR' => 1, 58 | 'AC_CANONICAL_SYSTEM' => 1, 59 | 'AC_REQUIRE_AUX_FILE' => 1, 60 | 'AC_CONFIG_LINKS' => 1, 61 | 'AM_PROG_CC_C_O' => 1, 62 | 'AM_INIT_AUTOMAKE' => 1, 63 | 'AC_FC_PP_SRCEXT' => 1, 64 | 'AC_FC_PP_DEFINE' => 1, 65 | 'm4_pattern_forbid' => 1, 66 | 'm4_pattern_allow' => 1, 67 | 'AC_LIBSOURCE' => 1, 68 | 'AM_SILENT_RULES' => 1, 69 | 'AM_PROG_CXX_C_O' => 1, 70 | 'include' => 1, 71 | 'AM_CONDITIONAL' => 1, 72 | 'AM_GNU_GETTEXT' => 1, 73 | 'AC_CANONICAL_TARGET' => 1, 74 | 'AM_AUTOMAKE_VERSION' => 1 75 | } 76 | ], 'Autom4te::Request' ) 77 | ); 78 | 79 | -------------------------------------------------------------------------------- /ext/kernel/exception.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | +------------------------------------------------------------------------+ 4 | | Zephir Language | 5 | +------------------------------------------------------------------------+ 6 | | Copyright (c) 2011-2014 Zephir Team (http://www.zephir-lang.com) | 7 | +------------------------------------------------------------------------+ 8 | | This source file is subject to the New BSD License that is bundled | 9 | | with this package in the file docs/LICENSE.txt. | 10 | | | 11 | | If you did not receive a copy of the license and are unable to | 12 | | obtain it through the world-wide-web, please send an email | 13 | | to license@zephir-lang.com so we can send you a copy immediately. | 14 | +------------------------------------------------------------------------+ 15 | | Authors: Andres Gutierrez | 16 | | Eduar Carvajal | 17 | | Vladimir Kolesnikov | 18 | +------------------------------------------------------------------------+ 19 | */ 20 | 21 | #ifndef ZEPHIR_KERNEL_EXCEPTIONS_H 22 | #define ZEPHIR_KERNEL_EXCEPTIONS_H 23 | 24 | #include "Zend/zend.h" 25 | 26 | /** Exceptions */ 27 | #define ZEPHIR_THROW_EXCEPTION_STR(class_entry, message) \ 28 | do { \ 29 | zephir_throw_exception_string(class_entry, message, strlen(message) TSRMLS_CC); \ 30 | ZEPHIR_MM_RESTORE(); \ 31 | } while (0) 32 | 33 | #define ZEPHIR_THROW_EXCEPTION_DEBUG_STR(class_entry, message, file, line) \ 34 | do { \ 35 | zephir_throw_exception_string_debug(class_entry, message, strlen(message), file, line TSRMLS_CC); \ 36 | ZEPHIR_MM_RESTORE(); \ 37 | } while (0) 38 | 39 | #define ZEPHIR_THROW_EXCEPTION_ZVAL(class_entry, message) \ 40 | do { \ 41 | zephir_throw_exception_zval(class_entry, message TSRMLS_CC); \ 42 | ZEPHIR_MM_RESTORE(); \ 43 | } while (0) 44 | 45 | #define ZEPHIR_THROW_EXCEPTION_DEBUG_ZVAL(class_entry, message, file, line) \ 46 | do { \ 47 | zephir_throw_exception_zval(class_entry, message, file, line TSRMLS_CC); \ 48 | ZEPHIR_MM_RESTORE(); \ 49 | } while (0) 50 | 51 | 52 | #define ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(class_entry, message, file, line) zephir_throw_exception_string_debug(class_entry, message, strlen(message), file, line TSRMLS_CC) 53 | #define ZEPHIR_THROW_EXCEPTION_STRW(class_entry, message) zephir_throw_exception_string(class_entry, message, strlen(message) TSRMLS_CC) 54 | #define ZEPHIR_THROW_EXCEPTION_ZVALW(class_entry, message) zephir_throw_exception_zval(class_entry, message TSRMLS_CC) 55 | #define ZEPHIR_THROW_EXCEPTION_DEBUG_ZVALW(class_entry, message, file, line) zephir_throw_exception_zval_debug(class_entry, message, file, line TSRMLS_CC) 56 | 57 | /** Throw Exceptions */ 58 | void zephir_throw_exception(zval *object TSRMLS_DC); 59 | void zephir_throw_exception_debug(zval *object, const char *file, zend_uint line TSRMLS_DC); 60 | void zephir_throw_exception_string_debug(zend_class_entry *ce, const char *message, zend_uint message_len, const char *file, zend_uint line TSRMLS_DC); 61 | void zephir_throw_exception_string(zend_class_entry *ce, const char *message, zend_uint message_len TSRMLS_DC); 62 | void zephir_throw_exception_zval(zend_class_entry *ce, zval *message TSRMLS_DC); 63 | void zephir_throw_exception_zval_debug(zend_class_entry *ce, zval *message, const char *file, zend_uint line TSRMLS_DC); 64 | void zephir_throw_exception_internal(zval *exception TSRMLS_DC); 65 | 66 | #endif /* ZEPHIR_KERNEL_EXCEPTIONS_H */ 67 | -------------------------------------------------------------------------------- /ext/kernel/variables.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | +------------------------------------------------------------------------+ 4 | | Zephir Language | 5 | +------------------------------------------------------------------------+ 6 | | Copyright (c) 2011-2014 Zephir Team (http://www.zephir-lang.com) | 7 | +------------------------------------------------------------------------+ 8 | | This source file is subject to the New BSD License that is bundled | 9 | | with this package in the file docs/LICENSE.txt. | 10 | | | 11 | | If you did not receive a copy of the license and are unable to | 12 | | obtain it through the world-wide-web, please send an email | 13 | | to license@zephir-lang.com so we can send you a copy immediately. | 14 | +------------------------------------------------------------------------+ 15 | | Authors: Andres Gutierrez | 16 | | Eduar Carvajal | 17 | | Rack Lin | 18 | +------------------------------------------------------------------------+ 19 | */ 20 | 21 | #ifdef HAVE_CONFIG_H 22 | #include "config.h" 23 | #endif 24 | 25 | #include "php.h" 26 | #include "php_ext.h" 27 | 28 | #include "ext/standard/php_smart_str.h" 29 | #include "ext/standard/php_var.h" 30 | 31 | /** 32 | * Serializes php variables without using the PHP userland 33 | */ 34 | void zephir_serialize(zval *return_value, zval **var TSRMLS_DC) { 35 | 36 | php_serialize_data_t var_hash; 37 | smart_str buf = {0}; 38 | 39 | PHP_VAR_SERIALIZE_INIT(var_hash); 40 | php_var_serialize(&buf, var, &var_hash TSRMLS_CC); 41 | PHP_VAR_SERIALIZE_DESTROY(var_hash); 42 | 43 | if (EG(exception)) { 44 | smart_str_free(&buf); 45 | RETURN_FALSE; 46 | } 47 | 48 | if (buf.c) { 49 | RETURN_STRINGL(buf.c, buf.len, 0); 50 | } else { 51 | RETURN_NULL(); 52 | } 53 | } 54 | 55 | /** 56 | * Unserializes php variables without using the PHP userland 57 | */ 58 | void zephir_unserialize(zval *return_value, zval *var TSRMLS_DC) { 59 | 60 | const unsigned char *p; 61 | php_unserialize_data_t var_hash; 62 | 63 | if (Z_TYPE_P(var) != IS_STRING) { 64 | RETURN_FALSE; 65 | } 66 | 67 | if (Z_STRLEN_P(var) == 0) { 68 | RETURN_FALSE; 69 | } 70 | 71 | p = (const unsigned char*) Z_STRVAL_P(var); 72 | PHP_VAR_UNSERIALIZE_INIT(var_hash); 73 | if (!php_var_unserialize(&return_value, &p, p + Z_STRLEN_P(var), &var_hash TSRMLS_CC)) { 74 | PHP_VAR_UNSERIALIZE_DESTROY(var_hash); 75 | zval_dtor(return_value); 76 | ZVAL_NULL(return_value); 77 | if (!EG(exception)) { 78 | php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Error at offset %ld of %d bytes", (long)((char*)p - Z_STRVAL_P(var)), Z_STRLEN_P(var)); 79 | } 80 | RETURN_FALSE; 81 | } 82 | PHP_VAR_UNSERIALIZE_DESTROY(var_hash); 83 | 84 | } 85 | 86 | /** 87 | * var_export outputs php variables without using the PHP userland 88 | */ 89 | void zephir_var_export(zval **var TSRMLS_DC) { 90 | php_var_export(var, 1 TSRMLS_CC); 91 | } 92 | 93 | /** 94 | * var_export returns php variables without using the PHP userland 95 | */ 96 | void zephir_var_export_ex(zval *return_value, zval **var TSRMLS_DC) { 97 | 98 | smart_str buf = { NULL, 0, 0 }; 99 | 100 | php_var_export_ex(var, 1, &buf TSRMLS_CC); 101 | smart_str_0(&buf); 102 | ZVAL_STRINGL(return_value, buf.c, buf.len, 0); 103 | } 104 | 105 | 106 | /** 107 | * var_dump outputs php variables without using the PHP userland 108 | */ 109 | void zephir_var_dump(zval **var TSRMLS_DC) { 110 | php_var_dump(var, 1 TSRMLS_CC); 111 | } 112 | 113 | -------------------------------------------------------------------------------- /ext/kernel/output.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | +------------------------------------------------------------------------+ 4 | | Zephir Language | 5 | +------------------------------------------------------------------------+ 6 | | Copyright (c) 2011-2014 Zephir Team (http://www.zephir-lang.com) | 7 | +------------------------------------------------------------------------+ 8 | | This source file is subject to the New BSD License that is bundled | 9 | | with this package in the file docs/LICENSE.txt. | 10 | | | 11 | | If you did not receive a copy of the license and are unable to | 12 | | obtain it through the world-wide-web, please send an email | 13 | | to license@zephir-lang.com so we can send you a copy immediately. | 14 | +------------------------------------------------------------------------+ 15 | | Authors: Andres Gutierrez | 16 | | Eduar Carvajal | 17 | | Vladimir Kolesnikov | 18 | +------------------------------------------------------------------------+ 19 | */ 20 | 21 | #ifdef HAVE_CONFIG_H 22 | #include "config.h" 23 | #endif 24 | 25 | #include "php.h" 26 | #include "php_ext.h" 27 | #include "kernel/memory.h" 28 | #include "kernel/output.h" 29 | 30 | #include 31 | #include
32 | 33 | void zephir_ob_start(TSRMLS_D) 34 | { 35 | #if PHP_VERSION_ID < 50400 36 | php_start_ob_buffer(NULL, 0, 1 TSRMLS_CC); 37 | #else 38 | php_output_start_default(TSRMLS_C); 39 | #endif 40 | } 41 | 42 | void zephir_ob_get_contents(zval *result TSRMLS_DC) 43 | { 44 | #if PHP_VERSION_ID < 50400 45 | php_ob_get_buffer(result TSRMLS_CC); 46 | #else 47 | php_output_get_contents(result TSRMLS_CC); 48 | #endif 49 | } 50 | 51 | int zephir_ob_end_flush(TSRMLS_D) 52 | { 53 | if (zephir_ob_get_level(TSRMLS_C) < 1) { 54 | php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete and flush buffer. No buffer to flush"); 55 | return FAILURE; 56 | } 57 | 58 | #if PHP_VERSION_ID < 50400 59 | php_end_ob_buffer(1, 0 TSRMLS_CC); 60 | return SUCCESS; 61 | #else 62 | return php_output_end(TSRMLS_C); 63 | #endif 64 | } 65 | 66 | int zephir_ob_end_clean(TSRMLS_D) 67 | { 68 | if (zephir_ob_get_level(TSRMLS_C) < 1) { 69 | php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer. No buffer to delete"); 70 | return FAILURE; 71 | } 72 | 73 | #if PHP_VERSION_ID < 50400 74 | php_end_ob_buffer(0, 0 TSRMLS_CC); 75 | return SUCCESS; 76 | #else 77 | return php_output_discard(TSRMLS_C); 78 | #endif 79 | } 80 | 81 | int zephir_ob_flush(TSRMLS_D) 82 | { 83 | if (zephir_ob_get_level(TSRMLS_C) < 1) { 84 | php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to flush buffer. No buffer to flush"); 85 | return FAILURE; 86 | } 87 | 88 | #if PHP_VERSION_ID < 50400 89 | php_end_ob_buffer(1, 1 TSRMLS_CC); 90 | return SUCCESS; 91 | #else 92 | return php_output_flush(TSRMLS_C); 93 | #endif 94 | } 95 | 96 | int zephir_ob_clean(TSRMLS_D) 97 | { 98 | if (zephir_ob_get_level(TSRMLS_C) < 1) { 99 | php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer. No buffer to delete"); 100 | return FAILURE; 101 | } 102 | 103 | #if PHP_VERSION_ID < 50400 104 | php_end_ob_buffer(0, 1 TSRMLS_CC); 105 | return SUCCESS; 106 | #else 107 | return php_output_clean(TSRMLS_C); 108 | #endif 109 | } 110 | 111 | int zephir_ob_get_level(TSRMLS_D) 112 | { 113 | #if PHP_VERSION_ID < 50400 114 | return OG(ob_nesting_level); 115 | #else 116 | return php_output_get_level(TSRMLS_C); 117 | #endif 118 | } 119 | -------------------------------------------------------------------------------- /ext/kernel/require.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | +------------------------------------------------------------------------+ 4 | | Zephir Language | 5 | +------------------------------------------------------------------------+ 6 | | Copyright (c) 2011-2014 Zephir Team (http://www.zephir-lang.com) | 7 | +------------------------------------------------------------------------+ 8 | | This source file is subject to the New BSD License that is bundled | 9 | | with this package in the file docs/LICENSE.txt. | 10 | | | 11 | | If you did not receive a copy of the license and are unable to | 12 | | obtain it through the world-wide-web, please send an email | 13 | | to license@zephir-lang.com so we can send you a copy immediately. | 14 | +------------------------------------------------------------------------+ 15 | | Authors: Andres Gutierrez | 16 | | Eduar Carvajal | 17 | | Vladimir Kolesnikov | 18 | +------------------------------------------------------------------------+ 19 | */ 20 | 21 | #ifdef HAVE_CONFIG_H 22 | #include "config.h" 23 | #endif 24 | 25 | #include "php.h" 26 | #include "php_ext.h" 27 | #include "kernel/require.h" 28 | #include "kernel/backtrace.h" 29 | 30 | #include
31 | #include 32 | 33 | #ifndef ENFORCE_SAFE_MODE 34 | #define ENFORCE_SAFE_MODE 0 35 | #endif 36 | 37 | /** 38 | * Do an internal require to a plain php file taking care of the value returned by the file 39 | */ 40 | int zephir_require_ret(zval **return_value_ptr, const char *require_path TSRMLS_DC) 41 | { 42 | zend_file_handle file_handle; 43 | int ret; 44 | 45 | #ifndef ZEPHIR_RELEASE 46 | if (return_value_ptr && *return_value_ptr) { 47 | fprintf(stderr, "%s: *return_value_ptr is expected to be NULL", __func__); 48 | zephir_print_backtrace(); 49 | abort(); 50 | } 51 | #endif 52 | 53 | if (!require_path) { 54 | /* @TODO, throw an exception here */ 55 | return FAILURE; 56 | } 57 | 58 | ret = php_stream_open_for_zend_ex(require_path, &file_handle, ENFORCE_SAFE_MODE | USE_PATH | STREAM_OPEN_FOR_INCLUDE | IGNORE_URL TSRMLS_CC); 59 | if (ret == SUCCESS) { 60 | int dummy = 1; 61 | zend_op_array *new_op_array; 62 | 63 | if (!file_handle.opened_path) { 64 | file_handle.opened_path = estrdup(require_path); 65 | } 66 | 67 | zend_hash_add(&EG(included_files), file_handle.opened_path, strlen(file_handle.opened_path)+1, (void *)&dummy, sizeof(int), NULL); 68 | new_op_array = zend_compile_file(&file_handle, ZEND_REQUIRE TSRMLS_CC); 69 | zend_destroy_file_handle(&file_handle TSRMLS_CC); 70 | 71 | if (new_op_array) { 72 | zval **original_return_value = EG(return_value_ptr_ptr); 73 | zend_op_array *original_active_op_array = EG(active_op_array); 74 | zend_op **original_opline_ptr = EG(opline_ptr); 75 | 76 | EG(return_value_ptr_ptr) = return_value_ptr; 77 | EG(active_op_array) = new_op_array; 78 | 79 | zend_execute(new_op_array TSRMLS_CC); 80 | zend_exception_restore(TSRMLS_C); 81 | destroy_op_array(new_op_array TSRMLS_CC); 82 | efree(new_op_array); 83 | 84 | if (EG(exception)) { 85 | assert(!return_value_ptr || !*return_value_ptr); 86 | ret = FAILURE; 87 | } 88 | else { 89 | ret = SUCCESS; 90 | } 91 | 92 | EG(return_value_ptr_ptr) = original_return_value; 93 | EG(active_op_array) = original_active_op_array; 94 | EG(opline_ptr) = original_opline_ptr; 95 | return ret; 96 | } 97 | } 98 | else { 99 | zend_destroy_file_handle(&file_handle TSRMLS_CC); 100 | } 101 | 102 | return FAILURE; 103 | } 104 | -------------------------------------------------------------------------------- /ext/kernel/array.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | +------------------------------------------------------------------------+ 4 | | Zephir Language | 5 | +------------------------------------------------------------------------+ 6 | | Copyright (c) 2011-2014 Zephir Team (http://www.zephir-lang.com) | 7 | +------------------------------------------------------------------------+ 8 | | This source file is subject to the New BSD License that is bundled | 9 | | with this package in the file docs/LICENSE.txt. | 10 | | | 11 | | If you did not receive a copy of the license and are unable to | 12 | | obtain it through the world-wide-web, please send an email | 13 | | to license@zephir-lang.com so we can send you a copy immediately. | 14 | +------------------------------------------------------------------------+ 15 | | Authors: Andres Gutierrez | 16 | | Eduar Carvajal | 17 | | Vladimir Kolesnikov | 18 | +------------------------------------------------------------------------+ 19 | */ 20 | 21 | #ifndef ZEPHIR_KERNEL_ARRAY_H 22 | #define ZEPHIR_KERNEL_ARRAY_H 23 | 24 | /** Combined isset/fetch */ 25 | int zephir_array_isset_fetch(zval **fetched, const zval *arr, zval *index, int readonly TSRMLS_DC); 26 | int zephir_array_isset_quick_string_fetch(zval **fetched, zval *arr, char *index, uint index_length, unsigned long key, int readonly TSRMLS_DC); 27 | int zephir_array_isset_string_fetch(zval **fetched, zval *arr, char *index, uint index_length, int readonly TSRMLS_DC); 28 | int zephir_array_isset_long_fetch(zval **fetched, zval *arr, unsigned long index, int readonly TSRMLS_DC); 29 | 30 | /** Check for index existence */ 31 | int ZEPHIR_FASTCALL zephir_array_isset(const zval *arr, zval *index); 32 | int ZEPHIR_FASTCALL zephir_array_isset_long(const zval *arr, unsigned long index); 33 | int ZEPHIR_FASTCALL zephir_array_isset_string(const zval *arr, const char *index, uint index_length); 34 | 35 | /** Fast index existence checking */ 36 | int ZEPHIR_FASTCALL zephir_array_isset_quick_string(const zval *arr, const char *index, uint index_length, unsigned long key); 37 | 38 | /** Unset existing indexes */ 39 | int ZEPHIR_FASTCALL zephir_array_unset(zval **arr, zval *index, int flags); 40 | int ZEPHIR_FASTCALL zephir_array_unset_long(zval **arr, unsigned long index, int flags); 41 | int ZEPHIR_FASTCALL zephir_array_unset_string(zval **arr, const char *index, uint index_length, int flags); 42 | 43 | /** Append elements to arrays */ 44 | int zephir_array_append(zval **arr, zval *value, int separate ZEPHIR_DEBUG_PARAMS); 45 | int zephir_array_append_long(zval **arr, long value, int separate); 46 | int zephir_array_append_string(zval **arr, char *value, uint value_length, int separate); 47 | 48 | /** Modify arrays */ 49 | int zephir_array_update_zval(zval **arr, zval *index, zval **value, int flags); 50 | int zephir_array_update_string(zval **arr, const char *index, uint index_length, zval **value, int flags); 51 | int zephir_array_update_long(zval **arr, unsigned long index, zval **value, int flags ZEPHIR_DEBUG_PARAMS); 52 | 53 | /** Fetch items from arrays */ 54 | int zephir_array_fetch(zval **return_value, zval *arr, zval *index, int flags ZEPHIR_DEBUG_PARAMS TSRMLS_DC); 55 | int zephir_array_fetch_string(zval **return_value, zval *arr, const char *index, uint index_length, int flags ZEPHIR_DEBUG_PARAMS TSRMLS_DC); 56 | int zephir_array_fetch_long(zval **return_value, zval *arr, unsigned long index, int flags ZEPHIR_DEBUG_PARAMS TSRMLS_DC); 57 | 58 | /** Merge+Append */ 59 | void zephir_merge_append(zval *left, zval *values); 60 | 61 | /* Traversing Arays */ 62 | void zephir_array_get_current(zval *return_value, zval *array); 63 | void zephir_array_next(zval *array); 64 | 65 | /* In Array */ 66 | int zephir_fast_in_array(zval *needle, zval *haystack TSRMLS_DC); 67 | 68 | /** Fast Array Merge */ 69 | void zephir_fast_array_merge(zval *return_value, zval **array1, zval **array2 TSRMLS_DC); 70 | 71 | /** Recursive merge */ 72 | void zephir_array_merge_recursive_n(zval **a1, zval *a2 TSRMLS_DC); 73 | 74 | void zephir_array_unshift(zval *arr, zval *arg TSRMLS_DC); 75 | void zephir_array_keys(zval *return_value, zval *arr TSRMLS_DC); 76 | void zephir_array_values(zval *return_value, zval *arr); 77 | int zephir_array_key_exists(zval *arr, zval *key TSRMLS_DC); 78 | int zephir_array_is_associative(zval *arr); 79 | 80 | int zephir_array_update_multi(zval **arr, zval **value TSRMLS_DC, const char *types, int types_length, int types_count, ...); 81 | 82 | #define zephir_array_fast_append(arr, value) \ 83 | Z_ADDREF_P(value); \ 84 | zend_hash_next_index_insert(Z_ARRVAL_P(arr), &value, sizeof(zval *), NULL); 85 | 86 | #endif /* ZEPHIR_KERNEL_ARRAY_H */ 87 | -------------------------------------------------------------------------------- /ext/build/ltsugar.m4: -------------------------------------------------------------------------------- 1 | # ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- 2 | # 3 | # Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. 4 | # Written by Gary V. Vaughan, 2004 5 | # 6 | # This file is free software; the Free Software Foundation gives 7 | # unlimited permission to copy and/or distribute it, with or without 8 | # modifications, as long as this notice is preserved. 9 | 10 | # serial 6 ltsugar.m4 11 | 12 | # This is to help aclocal find these macros, as it can't see m4_define. 13 | AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) 14 | 15 | 16 | # lt_join(SEP, ARG1, [ARG2...]) 17 | # ----------------------------- 18 | # Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their 19 | # associated separator. 20 | # Needed until we can rely on m4_join from Autoconf 2.62, since all earlier 21 | # versions in m4sugar had bugs. 22 | m4_define([lt_join], 23 | [m4_if([$#], [1], [], 24 | [$#], [2], [[$2]], 25 | [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) 26 | m4_define([_lt_join], 27 | [m4_if([$#$2], [2], [], 28 | [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) 29 | 30 | 31 | # lt_car(LIST) 32 | # lt_cdr(LIST) 33 | # ------------ 34 | # Manipulate m4 lists. 35 | # These macros are necessary as long as will still need to support 36 | # Autoconf-2.59 which quotes differently. 37 | m4_define([lt_car], [[$1]]) 38 | m4_define([lt_cdr], 39 | [m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], 40 | [$#], 1, [], 41 | [m4_dquote(m4_shift($@))])]) 42 | m4_define([lt_unquote], $1) 43 | 44 | 45 | # lt_append(MACRO-NAME, STRING, [SEPARATOR]) 46 | # ------------------------------------------ 47 | # Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'. 48 | # Note that neither SEPARATOR nor STRING are expanded; they are appended 49 | # to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). 50 | # No SEPARATOR is output if MACRO-NAME was previously undefined (different 51 | # than defined and empty). 52 | # 53 | # This macro is needed until we can rely on Autoconf 2.62, since earlier 54 | # versions of m4sugar mistakenly expanded SEPARATOR but not STRING. 55 | m4_define([lt_append], 56 | [m4_define([$1], 57 | m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) 58 | 59 | 60 | 61 | # lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) 62 | # ---------------------------------------------------------- 63 | # Produce a SEP delimited list of all paired combinations of elements of 64 | # PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list 65 | # has the form PREFIXmINFIXSUFFIXn. 66 | # Needed until we can rely on m4_combine added in Autoconf 2.62. 67 | m4_define([lt_combine], 68 | [m4_if(m4_eval([$# > 3]), [1], 69 | [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl 70 | [[m4_foreach([_Lt_prefix], [$2], 71 | [m4_foreach([_Lt_suffix], 72 | ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, 73 | [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) 74 | 75 | 76 | # lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) 77 | # ----------------------------------------------------------------------- 78 | # Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited 79 | # by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. 80 | m4_define([lt_if_append_uniq], 81 | [m4_ifdef([$1], 82 | [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], 83 | [lt_append([$1], [$2], [$3])$4], 84 | [$5])], 85 | [lt_append([$1], [$2], [$3])$4])]) 86 | 87 | 88 | # lt_dict_add(DICT, KEY, VALUE) 89 | # ----------------------------- 90 | m4_define([lt_dict_add], 91 | [m4_define([$1($2)], [$3])]) 92 | 93 | 94 | # lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) 95 | # -------------------------------------------- 96 | m4_define([lt_dict_add_subkey], 97 | [m4_define([$1($2:$3)], [$4])]) 98 | 99 | 100 | # lt_dict_fetch(DICT, KEY, [SUBKEY]) 101 | # ---------------------------------- 102 | m4_define([lt_dict_fetch], 103 | [m4_ifval([$3], 104 | m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), 105 | m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) 106 | 107 | 108 | # lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) 109 | # ----------------------------------------------------------------- 110 | m4_define([lt_if_dict_fetch], 111 | [m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], 112 | [$5], 113 | [$6])]) 114 | 115 | 116 | # lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) 117 | # -------------------------------------------------------------- 118 | m4_define([lt_dict_filter], 119 | [m4_if([$5], [], [], 120 | [lt_join(m4_quote(m4_default([$4], [[, ]])), 121 | lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), 122 | [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl 123 | ]) 124 | -------------------------------------------------------------------------------- /ext/kernel/exception.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | +------------------------------------------------------------------------+ 4 | | Zephir Language | 5 | +------------------------------------------------------------------------+ 6 | | Copyright (c) 2011-2014 Zephir Team (http://www.zephir-lang.com) | 7 | +------------------------------------------------------------------------+ 8 | | This source file is subject to the New BSD License that is bundled | 9 | | with this package in the file docs/LICENSE.txt. | 10 | | | 11 | | If you did not receive a copy of the license and are unable to | 12 | | obtain it through the world-wide-web, please send an email | 13 | | to license@zephir-lang.com so we can send you a copy immediately. | 14 | +------------------------------------------------------------------------+ 15 | | Authors: Andres Gutierrez | 16 | | Eduar Carvajal | 17 | | Vladimir Kolesnikov | 18 | +------------------------------------------------------------------------+ 19 | */ 20 | 21 | #ifdef HAVE_CONFIG_H 22 | #include "config.h" 23 | #endif 24 | 25 | #include "php.h" 26 | #include "php_ext.h" 27 | #include "php_main.h" 28 | #include "ext/standard/php_string.h" 29 | 30 | #include "kernel/main.h" 31 | #include "kernel/memory.h" 32 | #include "kernel/fcall.h" 33 | 34 | #include "Zend/zend_exceptions.h" 35 | 36 | /** 37 | * Throws a zval object as exception 38 | */ 39 | void zephir_throw_exception(zval *object TSRMLS_DC){ 40 | Z_ADDREF_P(object); 41 | zend_throw_exception_object(object TSRMLS_CC); 42 | } 43 | 44 | /** 45 | * Throws a zval object as exception 46 | */ 47 | void zephir_throw_exception_debug(zval *object, const char *file, zend_uint line TSRMLS_DC){ 48 | 49 | zend_class_entry *default_exception_ce; 50 | 51 | Z_ADDREF_P(object); 52 | 53 | if (line > 0) { 54 | default_exception_ce = zend_exception_get_default(TSRMLS_C); 55 | zend_update_property_string(default_exception_ce, object, "file", sizeof("file")-1, file TSRMLS_CC); 56 | zend_update_property_long(default_exception_ce, object, "line", sizeof("line")-1, line TSRMLS_CC); 57 | } 58 | 59 | zend_throw_exception_object(object TSRMLS_CC); 60 | } 61 | 62 | /** 63 | * Throws an exception with a single string parameter + debug info 64 | */ 65 | void zephir_throw_exception_string_debug(zend_class_entry *ce, const char *message, zend_uint message_len, const char *file, zend_uint line TSRMLS_DC) { 66 | 67 | zval *object, *msg; 68 | int ZEPHIR_LAST_CALL_STATUS = 0; 69 | zend_class_entry *default_exception_ce; 70 | 71 | ALLOC_INIT_ZVAL(object); 72 | object_init_ex(object, ce); 73 | 74 | ALLOC_INIT_ZVAL(msg); 75 | ZVAL_STRINGL(msg, message, message_len, 1); 76 | 77 | ZEPHIR_CALL_METHOD(NULL, object, "__construct", NULL, msg); 78 | zephir_check_call_status(); 79 | 80 | if (line > 0) { 81 | default_exception_ce = zend_exception_get_default(TSRMLS_C); 82 | zend_update_property_string(default_exception_ce, object, "file", sizeof("file")-1, file TSRMLS_CC); 83 | zend_update_property_long(default_exception_ce, object, "line", sizeof("line")-1, line TSRMLS_CC); 84 | } 85 | 86 | zend_throw_exception_object(object TSRMLS_CC); 87 | 88 | zval_ptr_dtor(&msg); 89 | } 90 | 91 | /** 92 | * Throws an exception with a single string parameter 93 | */ 94 | void zephir_throw_exception_string(zend_class_entry *ce, const char *message, zend_uint message_len TSRMLS_DC){ 95 | 96 | zval *object, *msg; 97 | int ZEPHIR_LAST_CALL_STATUS = 0; 98 | 99 | ALLOC_INIT_ZVAL(object); 100 | object_init_ex(object, ce); 101 | 102 | ALLOC_INIT_ZVAL(msg); 103 | ZVAL_STRINGL(msg, message, message_len, 1); 104 | 105 | ZEPHIR_CALL_METHOD(NULL, object, "__construct", NULL, msg); 106 | zephir_check_call_status(); 107 | 108 | zend_throw_exception_object(object TSRMLS_CC); 109 | 110 | zval_ptr_dtor(&msg); 111 | } 112 | 113 | /** 114 | * Throws an exception with a single zval parameter 115 | */ 116 | void zephir_throw_exception_zval_debug(zend_class_entry *ce, zval *message, const char *file, zend_uint line TSRMLS_DC){ 117 | 118 | zval *object; 119 | int ZEPHIR_LAST_CALL_STATUS = 0; 120 | zend_class_entry *default_exception_ce; 121 | 122 | ALLOC_INIT_ZVAL(object); 123 | object_init_ex(object, ce); 124 | 125 | ZEPHIR_CALL_METHOD(NULL, object, "__construct", NULL, message); 126 | zephir_check_call_status(); 127 | 128 | if (line > 0) { 129 | default_exception_ce = zend_exception_get_default(TSRMLS_C); 130 | zend_update_property_string(default_exception_ce, object, "file", sizeof("file")-1, file TSRMLS_CC); 131 | zend_update_property_long(default_exception_ce, object, "line", sizeof("line")-1, line TSRMLS_CC); 132 | } 133 | 134 | zend_throw_exception_object(object TSRMLS_CC); 135 | } 136 | 137 | /** 138 | * Throws an exception with a single zval parameter 139 | */ 140 | void zephir_throw_exception_zval(zend_class_entry *ce, zval *message TSRMLS_DC){ 141 | 142 | zval *object; 143 | int ZEPHIR_LAST_CALL_STATUS = 0; 144 | 145 | ALLOC_INIT_ZVAL(object); 146 | object_init_ex(object, ce); 147 | 148 | ZEPHIR_CALL_METHOD(NULL, object, "__construct", NULL, message); 149 | zephir_check_call_status(); 150 | 151 | zend_throw_exception_object(object TSRMLS_CC); 152 | } 153 | 154 | -------------------------------------------------------------------------------- /ext/kernel/globals.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | +------------------------------------------------------------------------+ 4 | | Zephir Language | 5 | +------------------------------------------------------------------------+ 6 | | Copyright (c) 2011-2014 Zephir Team (http://www.zephir-lang.com) | 7 | +------------------------------------------------------------------------+ 8 | | This source file is subject to the New BSD License that is bundled | 9 | | with this package in the file docs/LICENSE.txt. | 10 | | | 11 | | If you did not receive a copy of the license and are unable to | 12 | | obtain it through the world-wide-web, please send an email | 13 | | to license@zephir-lang.com so we can send you a copy immediately. | 14 | +------------------------------------------------------------------------+ 15 | | Authors: Andres Gutierrez | 16 | | Eduar Carvajal | 17 | | Vladimir Kolesnikov | 18 | +------------------------------------------------------------------------+ 19 | */ 20 | 21 | #ifndef ZEPHIR_KERNEL_GLOBALS_H 22 | #define ZEPHIR_KERNEL_GLOBALS_H 23 | 24 | #define ZEPHIR_MAX_MEMORY_STACK 48 25 | 26 | /** Memory frame */ 27 | typedef struct _zephir_memory_entry { 28 | size_t pointer; 29 | size_t capacity; 30 | zval ***addresses; 31 | size_t hash_pointer; 32 | size_t hash_capacity; 33 | zval ***hash_addresses; 34 | struct _zephir_memory_entry *prev; 35 | struct _zephir_memory_entry *next; 36 | #ifndef ZEPHIR_RELEASE 37 | const char *func; 38 | #endif 39 | } zephir_memory_entry; 40 | 41 | /** Virtual Symbol Table */ 42 | typedef struct _zephir_symbol_table { 43 | struct _zephir_memory_entry *scope; 44 | HashTable *symbol_table; 45 | struct _zephir_symbol_table *prev; 46 | } zephir_symbol_table; 47 | 48 | typedef struct _zephir_function_cache { 49 | zend_class_entry *ce; 50 | zend_function *func; 51 | } zephir_function_cache; 52 | 53 | #if PHP_VERSION_ID >= 50400 54 | #define ZEPHIR_INIT_FUNCS(class_functions) static const zend_function_entry class_functions[] = 55 | #else 56 | #define ZEPHIR_INIT_FUNCS(class_functions) static const function_entry class_functions[] = 57 | #endif 58 | 59 | #ifndef PHP_FE_END 60 | #define PHP_FE_END { NULL, NULL, NULL, 0, 0 } 61 | #endif 62 | 63 | /** Define FASTCALL */ 64 | #if defined(__GNUC__) && ZEND_GCC_VERSION >= 3004 && defined(__i386__) 65 | # define ZEPHIR_FASTCALL __attribute__((fastcall)) 66 | #elif defined(_MSC_VER) && defined(_M_IX86) 67 | # define ZEPHIR_FASTCALL __fastcall 68 | #else 69 | # define ZEPHIR_FASTCALL 70 | #endif 71 | 72 | #define ZEPHIR_INIT_CLASS(name) \ 73 | int zephir_ ##name## _init(INIT_FUNC_ARGS) 74 | 75 | #define ZEPHIR_INIT(name) \ 76 | if (zephir_ ##name## _init(INIT_FUNC_ARGS_PASSTHRU) == FAILURE) { \ 77 | return FAILURE; \ 78 | } 79 | 80 | /* Compatibility macros for PHP 5.3 */ 81 | #ifndef PHP_FE_END 82 | #define PHP_FE_END { NULL, NULL, NULL, 0, 0 } 83 | #endif 84 | 85 | #ifndef INIT_PZVAL_COPY 86 | # define INIT_PZVAL_COPY(z, v) \ 87 | ZVAL_COPY_VALUE(z, v); \ 88 | Z_SET_REFCOUNT_P(z, 1); \ 89 | Z_UNSET_ISREF_P(z); 90 | #endif 91 | 92 | #ifndef ZVAL_COPY_VALUE 93 | # define ZVAL_COPY_VALUE(z, v) \ 94 | (z)->value = (v)->value; \ 95 | Z_TYPE_P(z) = Z_TYPE_P(v); 96 | #endif 97 | 98 | #ifndef HASH_KEY_NON_EXISTENT 99 | # define HASH_KEY_NON_EXISTENT HASH_KEY_NON_EXISTANT 100 | #endif 101 | 102 | /** Macros for branch prediction */ 103 | #define likely(x) EXPECTED(x) 104 | #define unlikely(x) UNEXPECTED(x) 105 | 106 | #if defined(__GNUC__) && (defined(__clang__) || ((__GNUC__ * 100 + __GNUC_MINOR__) >= 405)) 107 | # define UNREACHABLE() __builtin_unreachable() 108 | # define ASSUME(x) if (x) {} else __builtin_unreachable() 109 | #else 110 | # define UNREACHABLE() assert(0) 111 | # define ASSUME(x) assert(!!(x)); 112 | #endif 113 | 114 | #if defined(__GNUC__) || defined(__clang__) 115 | # define ZEPHIR_ATTR_NONNULL __attribute__((nonnull)) 116 | # define ZEPHIR_ATTR_NONNULL1(x) __attribute__((nonnull (x))) 117 | # define ZEPHIR_ATTR_NONNULL2(x, y) __attribute__((nonnull (x, y))) 118 | # define ZEPHIR_ATTR_NONNULL3(x, y, z) __attribute__((nonnull (x, y, z))) 119 | # define ZEPHIR_ATTR_PURE __attribute__((pure)) 120 | # define ZEPHIR_ATTR_CONST __attribute__((const)) 121 | # define ZEPHIR_ATTR_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) 122 | #else 123 | # define ZEPHIR_ATTR_NONNULL 124 | # define ZEPHIR_ATTR_NONNULL1(x) 125 | # define ZEPHIR_ATTR_NONNULL2(x, y) 126 | # define ZEPHIR_ATTR_NONNULL3(x, y, z) 127 | # define ZEPHIR_ATTR_PURE 128 | # define ZEPHIR_ATTR_CONST 129 | # define ZEPHIR_ATTR_WARN_UNUSED_RESULT 130 | #endif 131 | 132 | #if !defined(__GNUC__) && !(defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) 133 | # define __builtin_constant_p(s) (0) 134 | #endif 135 | 136 | #ifndef ZEND_MOD_END 137 | # define ZEND_MOD_END { NULL, NULL, NULL, 0 } 138 | #endif 139 | 140 | #ifndef __func__ 141 | # define __func__ __FUNCTION__ 142 | #endif 143 | 144 | /*#if PHP_VERSION_ID > 50399 145 | # define ZLK_DC , const struct _zend_literal* key 146 | # define ZLK_CC , key 147 | # define ZLK_NULL_CC , NULL 148 | #else 149 | # define ZLK_DC 150 | # define ZLK_CC 151 | # define ZLK_NULL_CC 152 | #endif*/ 153 | 154 | #ifdef ZTS 155 | #define zephir_nts_static 156 | #else 157 | #define zephir_nts_static static 158 | #endif 159 | 160 | #define ZEPHIR_STATIC 161 | 162 | #endif 163 | -------------------------------------------------------------------------------- /ext/configure.in: -------------------------------------------------------------------------------- 1 | dnl This file becomes configure.in for self-contained extensions. 2 | 3 | AC_PREREQ(2.59) 4 | AC_INIT(config.m4) 5 | ifdef([AC_PRESERVE_HELP_ORDER], [AC_PRESERVE_HELP_ORDER], []) 6 | 7 | PHP_CONFIG_NICE(config.nice) 8 | 9 | dnl 10 | AC_DEFUN([PHP_EXT_BUILDDIR],[.])dnl 11 | AC_DEFUN([PHP_EXT_DIR],[""])dnl 12 | AC_DEFUN([PHP_EXT_SRCDIR],[$abs_srcdir])dnl 13 | AC_DEFUN([PHP_ALWAYS_SHARED],[ 14 | ext_output="yes, shared" 15 | ext_shared=yes 16 | test "[$]$1" = "no" && $1=yes 17 | ])dnl 18 | dnl 19 | 20 | test -z "$CFLAGS" && auto_cflags=1 21 | 22 | abs_srcdir=`(cd $srcdir && pwd)` 23 | abs_builddir=`pwd` 24 | 25 | AC_PROG_CC([cc gcc]) 26 | PHP_DETECT_ICC 27 | PHP_DETECT_SUNCC 28 | AC_PROG_CC_C_O 29 | 30 | dnl Support systems with system libraries in e.g. /usr/lib64 31 | PHP_ARG_WITH(libdir, for system library directory, 32 | [ --with-libdir=NAME Look for libraries in .../NAME rather than .../lib], lib, no) 33 | 34 | PHP_RUNPATH_SWITCH 35 | PHP_SHLIB_SUFFIX_NAMES 36 | 37 | dnl Find php-config script 38 | PHP_ARG_WITH(php-config,, 39 | [ --with-php-config=PATH Path to php-config [php-config]], php-config, no) 40 | 41 | dnl For BC 42 | PHP_CONFIG=$PHP_PHP_CONFIG 43 | prefix=`$PHP_CONFIG --prefix 2>/dev/null` 44 | phpincludedir=`$PHP_CONFIG --include-dir 2>/dev/null` 45 | INCLUDES=`$PHP_CONFIG --includes 2>/dev/null` 46 | EXTENSION_DIR=`$PHP_CONFIG --extension-dir 2>/dev/null` 47 | PHP_EXECUTABLE=`$PHP_CONFIG --php-binary 2>/dev/null` 48 | 49 | if test -z "$prefix"; then 50 | AC_MSG_ERROR([Cannot find php-config. Please use --with-php-config=PATH]) 51 | fi 52 | 53 | php_shtool=$srcdir/build/shtool 54 | PHP_INIT_BUILD_SYSTEM 55 | 56 | AC_MSG_CHECKING([for PHP prefix]) 57 | AC_MSG_RESULT([$prefix]) 58 | AC_MSG_CHECKING([for PHP includes]) 59 | AC_MSG_RESULT([$INCLUDES]) 60 | AC_MSG_CHECKING([for PHP extension directory]) 61 | AC_MSG_RESULT([$EXTENSION_DIR]) 62 | AC_MSG_CHECKING([for PHP installed headers prefix]) 63 | AC_MSG_RESULT([$phpincludedir]) 64 | 65 | dnl Checks for PHP_DEBUG / ZEND_DEBUG / ZTS 66 | AC_MSG_CHECKING([if debug is enabled]) 67 | old_CPPFLAGS=$CPPFLAGS 68 | CPPFLAGS="-I$phpincludedir" 69 | AC_EGREP_CPP(php_debug_is_enabled,[ 70 | #include
71 | #if ZEND_DEBUG 72 | php_debug_is_enabled 73 | #endif 74 | ],[ 75 | PHP_DEBUG=yes 76 | ],[ 77 | PHP_DEBUG=no 78 | ]) 79 | CPPFLAGS=$old_CPPFLAGS 80 | AC_MSG_RESULT([$PHP_DEBUG]) 81 | 82 | AC_MSG_CHECKING([if zts is enabled]) 83 | old_CPPFLAGS=$CPPFLAGS 84 | CPPFLAGS="-I$phpincludedir" 85 | AC_EGREP_CPP(php_zts_is_enabled,[ 86 | #include
87 | #if ZTS 88 | php_zts_is_enabled 89 | #endif 90 | ],[ 91 | PHP_THREAD_SAFETY=yes 92 | ],[ 93 | PHP_THREAD_SAFETY=no 94 | ]) 95 | CPPFLAGS=$old_CPPFLAGS 96 | AC_MSG_RESULT([$PHP_DEBUG]) 97 | 98 | dnl Support for building and testing Zend extensions 99 | ZEND_EXT_TYPE="zend_extension" 100 | PHP_SUBST(ZEND_EXT_TYPE) 101 | 102 | dnl Discard optimization flags when debugging is enabled 103 | if test "$PHP_DEBUG" = "yes"; then 104 | PHP_DEBUG=1 105 | ZEND_DEBUG=yes 106 | changequote({,}) 107 | CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9s]*//g'` 108 | CXXFLAGS=`echo "$CXXFLAGS" | $SED -e 's/-O[0-9s]*//g'` 109 | changequote([,]) 110 | dnl add -O0 only if GCC or ICC is used 111 | if test "$GCC" = "yes" || test "$ICC" = "yes"; then 112 | CFLAGS="$CFLAGS -O0" 113 | CXXFLAGS="$CXXFLAGS -g -O0" 114 | fi 115 | if test "$SUNCC" = "yes"; then 116 | if test -n "$auto_cflags"; then 117 | CFLAGS="-g" 118 | CXXFLAGS="-g" 119 | else 120 | CFLAGS="$CFLAGS -g" 121 | CXXFLAGS="$CFLAGS -g" 122 | fi 123 | fi 124 | else 125 | PHP_DEBUG=0 126 | ZEND_DEBUG=no 127 | fi 128 | 129 | dnl Always shared 130 | PHP_BUILD_SHARED 131 | 132 | dnl Required programs 133 | PHP_PROG_RE2C 134 | PHP_PROG_AWK 135 | 136 | sinclude(config.m4) 137 | 138 | enable_static=no 139 | enable_shared=yes 140 | 141 | dnl Only allow AC_PROG_CXX and AC_PROG_CXXCPP if they are explicitly called (by PHP_REQUIRE_CXX). 142 | dnl Otherwise AC_PROG_LIBTOOL fails if there is no working C++ compiler. 143 | AC_PROVIDE_IFELSE([PHP_REQUIRE_CXX], [], [ 144 | undefine([AC_PROG_CXX]) 145 | AC_DEFUN([AC_PROG_CXX], []) 146 | undefine([AC_PROG_CXXCPP]) 147 | AC_DEFUN([AC_PROG_CXXCPP], [php_prog_cxxcpp=disabled]) 148 | ]) 149 | AC_PROG_LIBTOOL 150 | 151 | all_targets='$(PHP_MODULES) $(PHP_ZEND_EX)' 152 | install_targets="install-modules install-headers" 153 | phplibdir="`pwd`/modules" 154 | CPPFLAGS="$CPPFLAGS -DHAVE_CONFIG_H" 155 | CFLAGS_CLEAN='$(CFLAGS)' 156 | CXXFLAGS_CLEAN='$(CXXFLAGS)' 157 | 158 | test "$prefix" = "NONE" && prefix="/usr/local" 159 | test "$exec_prefix" = "NONE" && exec_prefix='$(prefix)' 160 | 161 | PHP_SUBST(PHP_MODULES) 162 | PHP_SUBST(PHP_ZEND_EX) 163 | 164 | PHP_SUBST(all_targets) 165 | PHP_SUBST(install_targets) 166 | 167 | PHP_SUBST(prefix) 168 | PHP_SUBST(exec_prefix) 169 | PHP_SUBST(libdir) 170 | PHP_SUBST(prefix) 171 | PHP_SUBST(phplibdir) 172 | PHP_SUBST(phpincludedir) 173 | 174 | PHP_SUBST(CC) 175 | PHP_SUBST(CFLAGS) 176 | PHP_SUBST(CFLAGS_CLEAN) 177 | PHP_SUBST(CPP) 178 | PHP_SUBST(CPPFLAGS) 179 | PHP_SUBST(CXX) 180 | PHP_SUBST(CXXFLAGS) 181 | PHP_SUBST(CXXFLAGS_CLEAN) 182 | PHP_SUBST(EXTENSION_DIR) 183 | PHP_SUBST(PHP_EXECUTABLE) 184 | PHP_SUBST(EXTRA_LDFLAGS) 185 | PHP_SUBST(EXTRA_LIBS) 186 | PHP_SUBST(INCLUDES) 187 | PHP_SUBST(LFLAGS) 188 | PHP_SUBST(LDFLAGS) 189 | PHP_SUBST(SHARED_LIBTOOL) 190 | PHP_SUBST(LIBTOOL) 191 | PHP_SUBST(SHELL) 192 | PHP_SUBST(INSTALL_HEADERS) 193 | 194 | PHP_GEN_BUILD_DIRS 195 | PHP_GEN_GLOBAL_MAKEFILE 196 | 197 | test -d modules || $php_shtool mkdir modules 198 | touch .deps 199 | 200 | AC_CONFIG_HEADER(config.h) 201 | 202 | AC_OUTPUT() 203 | -------------------------------------------------------------------------------- /ext/Makefile.objects: -------------------------------------------------------------------------------- 1 | jalali.lo: /home/mohamad/projects/phpjalali/ext/jalali.c 2 | $(LIBTOOL) --mode=compile $(CC) -I. -I/home/mohamad/projects/phpjalali/ext $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) -c /home/mohamad/projects/phpjalali/ext/jalali.c -o jalali.lo 3 | kernel/main.lo: /home/mohamad/projects/phpjalali/ext/kernel/main.c 4 | $(LIBTOOL) --mode=compile $(CC) -I. -I/home/mohamad/projects/phpjalali/ext $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) -c /home/mohamad/projects/phpjalali/ext/kernel/main.c -o kernel/main.lo 5 | kernel/memory.lo: /home/mohamad/projects/phpjalali/ext/kernel/memory.c 6 | $(LIBTOOL) --mode=compile $(CC) -I. -I/home/mohamad/projects/phpjalali/ext $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) -c /home/mohamad/projects/phpjalali/ext/kernel/memory.c -o kernel/memory.lo 7 | kernel/exception.lo: /home/mohamad/projects/phpjalali/ext/kernel/exception.c 8 | $(LIBTOOL) --mode=compile $(CC) -I. -I/home/mohamad/projects/phpjalali/ext $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) -c /home/mohamad/projects/phpjalali/ext/kernel/exception.c -o kernel/exception.lo 9 | kernel/hash.lo: /home/mohamad/projects/phpjalali/ext/kernel/hash.c 10 | $(LIBTOOL) --mode=compile $(CC) -I. -I/home/mohamad/projects/phpjalali/ext $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) -c /home/mohamad/projects/phpjalali/ext/kernel/hash.c -o kernel/hash.lo 11 | kernel/debug.lo: /home/mohamad/projects/phpjalali/ext/kernel/debug.c 12 | $(LIBTOOL) --mode=compile $(CC) -I. -I/home/mohamad/projects/phpjalali/ext $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) -c /home/mohamad/projects/phpjalali/ext/kernel/debug.c -o kernel/debug.lo 13 | kernel/backtrace.lo: /home/mohamad/projects/phpjalali/ext/kernel/backtrace.c 14 | $(LIBTOOL) --mode=compile $(CC) -I. -I/home/mohamad/projects/phpjalali/ext $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) -c /home/mohamad/projects/phpjalali/ext/kernel/backtrace.c -o kernel/backtrace.lo 15 | kernel/object.lo: /home/mohamad/projects/phpjalali/ext/kernel/object.c 16 | $(LIBTOOL) --mode=compile $(CC) -I. -I/home/mohamad/projects/phpjalali/ext $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) -c /home/mohamad/projects/phpjalali/ext/kernel/object.c -o kernel/object.lo 17 | kernel/array.lo: /home/mohamad/projects/phpjalali/ext/kernel/array.c 18 | $(LIBTOOL) --mode=compile $(CC) -I. -I/home/mohamad/projects/phpjalali/ext $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) -c /home/mohamad/projects/phpjalali/ext/kernel/array.c -o kernel/array.lo 19 | kernel/extended/array.lo: /home/mohamad/projects/phpjalali/ext/kernel/extended/array.c 20 | $(LIBTOOL) --mode=compile $(CC) -I. -I/home/mohamad/projects/phpjalali/ext $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) -c /home/mohamad/projects/phpjalali/ext/kernel/extended/array.c -o kernel/extended/array.lo 21 | kernel/string.lo: /home/mohamad/projects/phpjalali/ext/kernel/string.c 22 | $(LIBTOOL) --mode=compile $(CC) -I. -I/home/mohamad/projects/phpjalali/ext $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) -c /home/mohamad/projects/phpjalali/ext/kernel/string.c -o kernel/string.lo 23 | kernel/fcall.lo: /home/mohamad/projects/phpjalali/ext/kernel/fcall.c 24 | $(LIBTOOL) --mode=compile $(CC) -I. -I/home/mohamad/projects/phpjalali/ext $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) -c /home/mohamad/projects/phpjalali/ext/kernel/fcall.c -o kernel/fcall.lo 25 | kernel/require.lo: /home/mohamad/projects/phpjalali/ext/kernel/require.c 26 | $(LIBTOOL) --mode=compile $(CC) -I. -I/home/mohamad/projects/phpjalali/ext $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) -c /home/mohamad/projects/phpjalali/ext/kernel/require.c -o kernel/require.lo 27 | kernel/file.lo: /home/mohamad/projects/phpjalali/ext/kernel/file.c 28 | $(LIBTOOL) --mode=compile $(CC) -I. -I/home/mohamad/projects/phpjalali/ext $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) -c /home/mohamad/projects/phpjalali/ext/kernel/file.c -o kernel/file.lo 29 | kernel/operators.lo: /home/mohamad/projects/phpjalali/ext/kernel/operators.c 30 | $(LIBTOOL) --mode=compile $(CC) -I. -I/home/mohamad/projects/phpjalali/ext $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) -c /home/mohamad/projects/phpjalali/ext/kernel/operators.c -o kernel/operators.lo 31 | kernel/concat.lo: /home/mohamad/projects/phpjalali/ext/kernel/concat.c 32 | $(LIBTOOL) --mode=compile $(CC) -I. -I/home/mohamad/projects/phpjalali/ext $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) -c /home/mohamad/projects/phpjalali/ext/kernel/concat.c -o kernel/concat.lo 33 | kernel/variables.lo: /home/mohamad/projects/phpjalali/ext/kernel/variables.c 34 | $(LIBTOOL) --mode=compile $(CC) -I. -I/home/mohamad/projects/phpjalali/ext $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) -c /home/mohamad/projects/phpjalali/ext/kernel/variables.c -o kernel/variables.lo 35 | kernel/filter.lo: /home/mohamad/projects/phpjalali/ext/kernel/filter.c 36 | $(LIBTOOL) --mode=compile $(CC) -I. -I/home/mohamad/projects/phpjalali/ext $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) -c /home/mohamad/projects/phpjalali/ext/kernel/filter.c -o kernel/filter.lo 37 | kernel/iterator.lo: /home/mohamad/projects/phpjalali/ext/kernel/iterator.c 38 | $(LIBTOOL) --mode=compile $(CC) -I. -I/home/mohamad/projects/phpjalali/ext $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) -c /home/mohamad/projects/phpjalali/ext/kernel/iterator.c -o kernel/iterator.lo 39 | kernel/exit.lo: /home/mohamad/projects/phpjalali/ext/kernel/exit.c 40 | $(LIBTOOL) --mode=compile $(CC) -I. -I/home/mohamad/projects/phpjalali/ext $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) -c /home/mohamad/projects/phpjalali/ext/kernel/exit.c -o kernel/exit.lo 41 | jalali/date.lo: /home/mohamad/projects/phpjalali/ext/jalali/date.zep.c 42 | $(LIBTOOL) --mode=compile $(CC) -I. -I/home/mohamad/projects/phpjalali/ext $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) -c /home/mohamad/projects/phpjalali/ext/jalali/date.zep.c -o jalali/date.lo 43 | $(phplibdir)/jalali.la: ./jalali.la 44 | $(LIBTOOL) --mode=install cp ./jalali.la $(phplibdir) 45 | 46 | ./jalali.la: $(shared_objects_jalali) $(JALALI_SHARED_DEPENDENCIES) 47 | $(LIBTOOL) --mode=link $(CC) $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) -o $@ -export-dynamic -avoid-version -prefer-pic -module -rpath $(phplibdir) $(EXTRA_LDFLAGS) $(shared_objects_jalali) $(JALALI_SHARED_LIBADD) 48 | 49 | -------------------------------------------------------------------------------- /ext/build/lt~obsolete.m4: -------------------------------------------------------------------------------- 1 | # lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- 2 | # 3 | # Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc. 4 | # Written by Scott James Remnant, 2004. 5 | # 6 | # This file is free software; the Free Software Foundation gives 7 | # unlimited permission to copy and/or distribute it, with or without 8 | # modifications, as long as this notice is preserved. 9 | 10 | # serial 5 lt~obsolete.m4 11 | 12 | # These exist entirely to fool aclocal when bootstrapping libtool. 13 | # 14 | # In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN) 15 | # which have later been changed to m4_define as they aren't part of the 16 | # exported API, or moved to Autoconf or Automake where they belong. 17 | # 18 | # The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN 19 | # in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us 20 | # using a macro with the same name in our local m4/libtool.m4 it'll 21 | # pull the old libtool.m4 in (it doesn't see our shiny new m4_define 22 | # and doesn't know about Autoconf macros at all.) 23 | # 24 | # So we provide this file, which has a silly filename so it's always 25 | # included after everything else. This provides aclocal with the 26 | # AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything 27 | # because those macros already exist, or will be overwritten later. 28 | # We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. 29 | # 30 | # Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here. 31 | # Yes, that means every name once taken will need to remain here until 32 | # we give up compatibility with versions before 1.7, at which point 33 | # we need to keep only those names which we still refer to. 34 | 35 | # This is to help aclocal find these macros, as it can't see m4_define. 36 | AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])]) 37 | 38 | m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])]) 39 | m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])]) 40 | m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])]) 41 | m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])]) 42 | m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])]) 43 | m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])]) 44 | m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])]) 45 | m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])]) 46 | m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])]) 47 | m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])]) 48 | m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])]) 49 | m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])]) 50 | m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])]) 51 | m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])]) 52 | m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])]) 53 | m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])]) 54 | m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])]) 55 | m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])]) 56 | m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])]) 57 | m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])]) 58 | m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])]) 59 | m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])]) 60 | m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])]) 61 | m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])]) 62 | m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])]) 63 | m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])]) 64 | m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])]) 65 | m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])]) 66 | m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])]) 67 | m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])]) 68 | m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])]) 69 | m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])]) 70 | m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])]) 71 | m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])]) 72 | m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])]) 73 | m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])]) 74 | m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])]) 75 | m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])]) 76 | m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])]) 77 | m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) 78 | m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) 79 | m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) 80 | m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) 81 | m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) 82 | m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) 83 | m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])]) 84 | m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])]) 85 | m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])]) 86 | m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])]) 87 | m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])]) 88 | m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])]) 89 | m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) 90 | m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) 91 | m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) 92 | m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])]) 93 | m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])]) 94 | m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])]) 95 | m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])]) 96 | m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])]) 97 | m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])]) 98 | m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])]) 99 | -------------------------------------------------------------------------------- /ext/kernel/string.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | +------------------------------------------------------------------------+ 4 | | Zephir Language | 5 | +------------------------------------------------------------------------+ 6 | | Copyright (c) 2011-2014 Zephir Team (http://www.zephir-lang.com) | 7 | +------------------------------------------------------------------------+ 8 | | This source file is subject to the New BSD License that is bundled | 9 | | with this package in the file docs/LICENSE.txt. | 10 | | | 11 | | If you did not receive a copy of the license and are unable to | 12 | | obtain it through the world-wide-web, please send an email | 13 | | to license@zephir-lang.com so we can send you a copy immediately. | 14 | +------------------------------------------------------------------------+ 15 | | Authors: Andres Gutierrez | 16 | | Eduar Carvajal | 17 | | Vladimir Kolesnikov | 18 | +------------------------------------------------------------------------+ 19 | */ 20 | 21 | #ifndef ZEPHIR_KERNEL_STRING_H 22 | #define ZEPHIR_KERNEL_STRING_H 23 | 24 | #include 25 | 26 | #define ZEPHIR_TRIM_LEFT 1 27 | #define ZEPHIR_TRIM_RIGHT 2 28 | #define ZEPHIR_TRIM_BOTH 3 29 | 30 | /** Fast char position */ 31 | int zephir_memnstr(const zval *haystack, const zval *needle ZEPHIR_DEBUG_PARAMS); 32 | int zephir_memnstr_str(const zval *haystack, char *needle, unsigned int needle_length ZEPHIR_DEBUG_PARAMS); 33 | 34 | /** Function replacement */ 35 | void zephir_fast_strlen(zval *return_value, zval *str); 36 | int zephir_fast_strlen_ev(zval *str); 37 | void zephir_fast_strtolower(zval *return_value, zval *str); 38 | void zephir_strtolower_inplace(zval *s); 39 | void zephir_fast_join(zval *result, zval *glue, zval *pieces TSRMLS_DC); 40 | void zephir_fast_join_str(zval *result, char *glue, unsigned int glue_length, zval *pieces TSRMLS_DC); 41 | void zephir_fast_explode(zval *result, zval *delimiter, zval *str, long limit TSRMLS_DC); 42 | void zephir_fast_explode_str(zval *result, const char *delimiter, int delimiter_length, zval *str, long limit TSRMLS_DC); 43 | void zephir_fast_strpos(zval *return_value, const zval *haystack, const zval *needle, unsigned int offset); 44 | void zephir_fast_strpos_str(zval *return_value, const zval *haystack, char *needle, unsigned int needle_length); 45 | void zephir_fast_stripos_str(zval *return_value, zval *haystack, char *needle, unsigned int needle_length); 46 | void zephir_fast_str_replace(zval *return_value, zval *search, zval *replace, zval *subject); 47 | void zephir_fast_trim(zval *return_value, zval *str, zval *charlist, int where TSRMLS_DC); 48 | void zephir_fast_strip_tags(zval *return_value, zval *str); 49 | void zephir_fast_strtoupper(zval *return_value, zval *str); 50 | 51 | /** Camelize/Uncamelize */ 52 | void zephir_camelize(zval *return_value, const zval *str); 53 | void zephir_uncamelize(zval *return_value, const zval *str); 54 | 55 | /** Starts/Ends with */ 56 | int zephir_start_with(const zval *str, const zval *compared, zval *case_sensitive); 57 | int zephir_start_with_str(const zval *str, char *compared, unsigned int compared_length); 58 | int zephir_start_with_str_str(char *str, unsigned int str_length, char *compared, unsigned int compared_length); 59 | int zephir_end_with(const zval *str, const zval *compared, zval *case_sensitive); 60 | int zephir_end_with_str(const zval *str, char *compared, unsigned int compared_length); 61 | 62 | /** Random string */ 63 | void zephir_random_string(zval *return_value, const zval *type, const zval *length TSRMLS_DC); 64 | 65 | /* Strips extra slashes */ 66 | void zephir_remove_extra_slashes(zval *return_value, const zval *str); 67 | 68 | /** Generates a unique key for an array/object */ 69 | void zephir_unique_key(zval *return_value, zval *prefix, zval *value TSRMLS_DC); 70 | 71 | /** spprintf */ 72 | int zephir_spprintf(char **message, int max_len, char *format, ...); 73 | 74 | /* Substr */ 75 | void zephir_substr(zval *return_value, zval *str, long from, long length); 76 | 77 | /** EOL */ 78 | zval *zephir_eol(int eol TSRMLS_DC); 79 | 80 | /** Preg-Match */ 81 | void zephir_preg_match(zval *return_value, zval **return_value_ptr, zval *regex, zval *subject, zval *matches, int global, long flags, long offset TSRMLS_DC); 82 | 83 | /** Base64 */ 84 | void zephir_base64_encode(zval *return_value, zval *data); 85 | void zephir_base64_decode(zval *return_value, zval *data); 86 | 87 | /** Hash */ 88 | void zephir_md5(zval *return_value, zval *str); 89 | 90 | /** JSON */ 91 | int zephir_json_encode(zval *return_value, zval **return_value_ptr, zval *v, int opts TSRMLS_DC); 92 | int zephir_json_decode(zval *return_value, zval **return_value_ptr, zval *v, zend_bool assoc TSRMLS_DC); 93 | 94 | /***/ 95 | void zephir_lcfirst(zval *return_value, zval *s); 96 | void zephir_ucfirst(zval *return_value, zval *s); 97 | int zephir_http_build_query(zval *return_value, zval *params, char *sep TSRMLS_DC); 98 | void zephir_htmlspecialchars(zval *return_value, zval *string, zval *quoting, zval *charset TSRMLS_DC); 99 | void zephir_htmlentities(zval *return_value, zval *string, zval *quoting, zval *charset TSRMLS_DC); 100 | void zephir_strval(zval *return_value, zval *v); 101 | void zephir_date(zval *return_value, zval *format, zval *timestamp TSRMLS_DC); 102 | void zephir_addslashes(zval *return_value, zval *str TSRMLS_DC); 103 | void zephir_stripslashes(zval *return_value, zval *str TSRMLS_DC); 104 | void zephir_stripcslashes(zval *return_value, zval *str TSRMLS_DC); 105 | 106 | #if PHP_VERSION_ID < 50400 107 | 108 | const char* zend_new_interned_string(const char *arKey, int nKeyLength, int free_src TSRMLS_DC); 109 | #define ZEPHIR_ZVAL_MAYBE_INTERNED_STRING(pz, string) ZVAL_STRING(pz, string, 1); 110 | 111 | #else 112 | 113 | #define ZEPHIR_ZVAL_MAYBE_INTERNED_STRING(pz, string) \ 114 | do { \ 115 | if (IS_INTERNED(string)) { \ 116 | ZVAL_STRINGL(pz, string, INTERNED_LEN(string)-1, 0); \ 117 | } \ 118 | else { \ 119 | ZVAL_STRING(pz, string, 1); \ 120 | } \ 121 | } while (0) 122 | 123 | #endif /* PHP_VERSION_ID < 50400 */ 124 | 125 | #endif /* ZEPHIR_KERNEL_STRING_H */ 126 | -------------------------------------------------------------------------------- /ext/kernel/concat.c: -------------------------------------------------------------------------------- 1 | 2 | #ifdef HAVE_CONFIG_H 3 | #include "config.h" 4 | #endif 5 | 6 | #include "php.h" 7 | #include "php_ext.h" 8 | #include "ext/standard/php_string.h" 9 | #include "ext.h" 10 | 11 | #include "kernel/main.h" 12 | #include "kernel/memory.h" 13 | #include "kernel/concat.h" 14 | 15 | void zephir_concat_sv(zval **result, const char *op1, zend_uint op1_len, zval *op2, int self_var TSRMLS_DC){ 16 | 17 | zval result_copy, op2_copy; 18 | int use_copy = 0, use_copy2 = 0; 19 | uint offset = 0, length; 20 | 21 | if (Z_TYPE_P(op2) != IS_STRING) { 22 | zend_make_printable_zval(op2, &op2_copy, &use_copy2); 23 | if (use_copy2) { 24 | op2 = &op2_copy; 25 | } 26 | } 27 | 28 | length = op1_len + Z_STRLEN_P(op2); 29 | if (self_var) { 30 | 31 | if (Z_TYPE_PP(result) != IS_STRING) { 32 | zend_make_printable_zval(*result, &result_copy, &use_copy); 33 | if (use_copy) { 34 | ZEPHIR_CPY_WRT_CTOR(*result, (&result_copy)); 35 | } 36 | } 37 | 38 | offset = Z_STRLEN_PP(result); 39 | length += offset; 40 | Z_STRVAL_PP(result) = (char *) erealloc(Z_STRVAL_PP(result), length + 1); 41 | 42 | } else { 43 | Z_STRVAL_PP(result) = (char *) emalloc(length + 1); 44 | } 45 | 46 | memcpy(Z_STRVAL_PP(result) + offset, op1, op1_len); 47 | memcpy(Z_STRVAL_PP(result) + offset + op1_len, Z_STRVAL_P(op2), Z_STRLEN_P(op2)); 48 | Z_STRVAL_PP(result)[length] = 0; 49 | Z_TYPE_PP(result) = IS_STRING; 50 | Z_STRLEN_PP(result) = length; 51 | 52 | if (use_copy2) { 53 | zval_dtor(op2); 54 | } 55 | 56 | if (use_copy) { 57 | zval_dtor(&result_copy); 58 | } 59 | 60 | } 61 | 62 | void zephir_concat_vs(zval **result, zval *op1, const char *op2, zend_uint op2_len, int self_var TSRMLS_DC){ 63 | 64 | zval result_copy, op1_copy; 65 | int use_copy = 0, use_copy1 = 0; 66 | uint offset = 0, length; 67 | 68 | if (Z_TYPE_P(op1) != IS_STRING) { 69 | zend_make_printable_zval(op1, &op1_copy, &use_copy1); 70 | if (use_copy1) { 71 | op1 = &op1_copy; 72 | } 73 | } 74 | 75 | length = Z_STRLEN_P(op1) + op2_len; 76 | if (self_var) { 77 | 78 | if (Z_TYPE_PP(result) != IS_STRING) { 79 | zend_make_printable_zval(*result, &result_copy, &use_copy); 80 | if (use_copy) { 81 | ZEPHIR_CPY_WRT_CTOR(*result, (&result_copy)); 82 | } 83 | } 84 | 85 | offset = Z_STRLEN_PP(result); 86 | length += offset; 87 | Z_STRVAL_PP(result) = (char *) erealloc(Z_STRVAL_PP(result), length + 1); 88 | 89 | } else { 90 | Z_STRVAL_PP(result) = (char *) emalloc(length + 1); 91 | } 92 | 93 | memcpy(Z_STRVAL_PP(result) + offset, Z_STRVAL_P(op1), Z_STRLEN_P(op1)); 94 | memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1), op2, op2_len); 95 | Z_STRVAL_PP(result)[length] = 0; 96 | Z_TYPE_PP(result) = IS_STRING; 97 | Z_STRLEN_PP(result) = length; 98 | 99 | if (use_copy1) { 100 | zval_dtor(op1); 101 | } 102 | 103 | if (use_copy) { 104 | zval_dtor(&result_copy); 105 | } 106 | 107 | } 108 | 109 | void zephir_concat_vv(zval **result, zval *op1, zval *op2, int self_var TSRMLS_DC){ 110 | 111 | zval result_copy, op1_copy, op2_copy; 112 | int use_copy = 0, use_copy1 = 0, use_copy2 = 0; 113 | uint offset = 0, length; 114 | 115 | if (Z_TYPE_P(op1) != IS_STRING) { 116 | zend_make_printable_zval(op1, &op1_copy, &use_copy1); 117 | if (use_copy1) { 118 | op1 = &op1_copy; 119 | } 120 | } 121 | 122 | if (Z_TYPE_P(op2) != IS_STRING) { 123 | zend_make_printable_zval(op2, &op2_copy, &use_copy2); 124 | if (use_copy2) { 125 | op2 = &op2_copy; 126 | } 127 | } 128 | 129 | length = Z_STRLEN_P(op1) + Z_STRLEN_P(op2); 130 | if (self_var) { 131 | 132 | if (Z_TYPE_PP(result) != IS_STRING) { 133 | zend_make_printable_zval(*result, &result_copy, &use_copy); 134 | if (use_copy) { 135 | ZEPHIR_CPY_WRT_CTOR(*result, (&result_copy)); 136 | } 137 | } 138 | 139 | offset = Z_STRLEN_PP(result); 140 | length += offset; 141 | Z_STRVAL_PP(result) = (char *) erealloc(Z_STRVAL_PP(result), length + 1); 142 | 143 | } else { 144 | Z_STRVAL_PP(result) = (char *) emalloc(length + 1); 145 | } 146 | 147 | memcpy(Z_STRVAL_PP(result) + offset, Z_STRVAL_P(op1), Z_STRLEN_P(op1)); 148 | memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1), Z_STRVAL_P(op2), Z_STRLEN_P(op2)); 149 | Z_STRVAL_PP(result)[length] = 0; 150 | Z_TYPE_PP(result) = IS_STRING; 151 | Z_STRLEN_PP(result) = length; 152 | 153 | if (use_copy1) { 154 | zval_dtor(op1); 155 | } 156 | 157 | if (use_copy2) { 158 | zval_dtor(op2); 159 | } 160 | 161 | if (use_copy) { 162 | zval_dtor(&result_copy); 163 | } 164 | 165 | } 166 | 167 | void zephir_concat_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ 168 | { 169 | #if PHP_VERSION_ID < 50400 170 | zval op1_copy, op2_copy; 171 | int use_copy1 = 0, use_copy2 = 0; 172 | 173 | if (Z_TYPE_P(op1) != IS_STRING) { 174 | zend_make_printable_zval(op1, &op1_copy, &use_copy1); 175 | } 176 | if (Z_TYPE_P(op2) != IS_STRING) { 177 | zend_make_printable_zval(op2, &op2_copy, &use_copy2); 178 | } 179 | 180 | if (use_copy1) { 181 | /* We have created a converted copy of op1. Therefore, op1 won't become the result so 182 | * we have to free it. 183 | */ 184 | if (result == op1) { 185 | zval_dtor(op1); 186 | } 187 | op1 = &op1_copy; 188 | } 189 | if (use_copy2) { 190 | op2 = &op2_copy; 191 | } 192 | if (result==op1 && !IS_INTERNED(Z_STRVAL_P(op1))) { /* special case, perform operations on result */ 193 | uint res_len = Z_STRLEN_P(op1) + Z_STRLEN_P(op2); 194 | 195 | if (Z_STRLEN_P(result) < 0 || (int) (Z_STRLEN_P(op1) + Z_STRLEN_P(op2)) < 0) { 196 | efree(Z_STRVAL_P(result)); 197 | ZVAL_EMPTY_STRING(result); 198 | zend_error(E_ERROR, "String size overflow"); 199 | } 200 | 201 | Z_STRVAL_P(result) = erealloc(Z_STRVAL_P(result), res_len+1); 202 | 203 | memcpy(Z_STRVAL_P(result)+Z_STRLEN_P(result), Z_STRVAL_P(op2), Z_STRLEN_P(op2)); 204 | Z_STRVAL_P(result)[res_len]=0; 205 | Z_STRLEN_P(result) = res_len; 206 | } else { 207 | int length = Z_STRLEN_P(op1) + Z_STRLEN_P(op2); 208 | char *buf = (char *) emalloc(length + 1); 209 | 210 | memcpy(buf, Z_STRVAL_P(op1), Z_STRLEN_P(op1)); 211 | memcpy(buf + Z_STRLEN_P(op1), Z_STRVAL_P(op2), Z_STRLEN_P(op2)); 212 | buf[length] = 0; 213 | ZVAL_STRINGL(result, buf, length, 0); 214 | } 215 | if (use_copy1) { 216 | zval_dtor(op1); 217 | } 218 | if (use_copy2) { 219 | zval_dtor(op2); 220 | } 221 | #else 222 | concat_function(result, op1, op2 TSRMLS_CC); 223 | #endif 224 | } -------------------------------------------------------------------------------- /ext/Makefile.global: -------------------------------------------------------------------------------- 1 | mkinstalldirs = $(top_srcdir)/build/shtool mkdir -p 2 | INSTALL = $(top_srcdir)/build/shtool install -c 3 | INSTALL_DATA = $(INSTALL) -m 644 4 | 5 | DEFS = -DPHP_ATOM_INC -I$(top_builddir)/include -I$(top_builddir)/main -I$(top_srcdir) 6 | COMMON_FLAGS = $(DEFS) $(INCLUDES) $(EXTRA_INCLUDES) $(CPPFLAGS) $(PHP_FRAMEWORKPATH) 7 | 8 | all: $(all_targets) 9 | @echo 10 | @echo "Build complete." 11 | @echo "Don't forget to run 'make test'." 12 | @echo 13 | 14 | build-modules: $(PHP_MODULES) $(PHP_ZEND_EX) 15 | 16 | build-binaries: $(PHP_BINARIES) 17 | 18 | libphp$(PHP_MAJOR_VERSION).la: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS) 19 | $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -rpath $(phptempdir) $(EXTRA_LDFLAGS) $(LDFLAGS) $(PHP_RPATHS) $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@ 20 | -@$(LIBTOOL) --silent --mode=install cp $@ $(phptempdir)/$@ >/dev/null 2>&1 21 | 22 | libs/libphp$(PHP_MAJOR_VERSION).bundle: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS) 23 | $(CC) $(MH_BUNDLE_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(PHP_GLOBAL_OBJS:.lo=.o) $(PHP_SAPI_OBJS:.lo=.o) $(PHP_FRAMEWORKS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@ && cp $@ libs/libphp$(PHP_MAJOR_VERSION).so 24 | 25 | install: $(all_targets) $(install_targets) 26 | 27 | install-sapi: $(OVERALL_TARGET) 28 | @echo "Installing PHP SAPI module: $(PHP_SAPI)" 29 | -@$(mkinstalldirs) $(INSTALL_ROOT)$(bindir) 30 | -@if test ! -r $(phptempdir)/libphp$(PHP_MAJOR_VERSION).$(SHLIB_DL_SUFFIX_NAME); then \ 31 | for i in 0.0.0 0.0 0; do \ 32 | if test -r $(phptempdir)/libphp$(PHP_MAJOR_VERSION).$(SHLIB_DL_SUFFIX_NAME).$$i; then \ 33 | $(LN_S) $(phptempdir)/libphp$(PHP_MAJOR_VERSION).$(SHLIB_DL_SUFFIX_NAME).$$i $(phptempdir)/libphp$(PHP_MAJOR_VERSION).$(SHLIB_DL_SUFFIX_NAME); \ 34 | break; \ 35 | fi; \ 36 | done; \ 37 | fi 38 | @$(INSTALL_IT) 39 | 40 | install-binaries: build-binaries $(install_binary_targets) 41 | 42 | install-modules: build-modules 43 | @test -d modules && \ 44 | $(mkinstalldirs) $(INSTALL_ROOT)$(EXTENSION_DIR) 45 | @echo "Installing shared extensions: $(INSTALL_ROOT)$(EXTENSION_DIR)/" 46 | @rm -f modules/*.la >/dev/null 2>&1 47 | @$(INSTALL) modules/* $(INSTALL_ROOT)$(EXTENSION_DIR) 48 | 49 | install-headers: 50 | -@if test "$(INSTALL_HEADERS)"; then \ 51 | for i in `echo $(INSTALL_HEADERS)`; do \ 52 | i=`$(top_srcdir)/build/shtool path -d $$i`; \ 53 | paths="$$paths $(INSTALL_ROOT)$(phpincludedir)/$$i"; \ 54 | done; \ 55 | $(mkinstalldirs) $$paths && \ 56 | echo "Installing header files: $(INSTALL_ROOT)$(phpincludedir)/" && \ 57 | for i in `echo $(INSTALL_HEADERS)`; do \ 58 | if test "$(PHP_PECL_EXTENSION)"; then \ 59 | src=`echo $$i | $(SED) -e "s#ext/$(PHP_PECL_EXTENSION)/##g"`; \ 60 | else \ 61 | src=$$i; \ 62 | fi; \ 63 | if test -f "$(top_srcdir)/$$src"; then \ 64 | $(INSTALL_DATA) $(top_srcdir)/$$src $(INSTALL_ROOT)$(phpincludedir)/$$i; \ 65 | elif test -f "$(top_builddir)/$$src"; then \ 66 | $(INSTALL_DATA) $(top_builddir)/$$src $(INSTALL_ROOT)$(phpincludedir)/$$i; \ 67 | else \ 68 | (cd $(top_srcdir)/$$src && $(INSTALL_DATA) *.h $(INSTALL_ROOT)$(phpincludedir)/$$i; \ 69 | cd $(top_builddir)/$$src && $(INSTALL_DATA) *.h $(INSTALL_ROOT)$(phpincludedir)/$$i) 2>/dev/null || true; \ 70 | fi \ 71 | done; \ 72 | fi 73 | 74 | PHP_TEST_SETTINGS = -d 'open_basedir=' -d 'output_buffering=0' -d 'memory_limit=-1' 75 | PHP_TEST_SHARED_EXTENSIONS = ` \ 76 | if test "x$(PHP_MODULES)" != "x"; then \ 77 | for i in $(PHP_MODULES)""; do \ 78 | . $$i; $(top_srcdir)/build/shtool echo -n -- " -d extension=$$dlname"; \ 79 | done; \ 80 | fi; \ 81 | if test "x$(PHP_ZEND_EX)" != "x"; then \ 82 | for i in $(PHP_ZEND_EX)""; do \ 83 | . $$i; $(top_srcdir)/build/shtool echo -n -- " -d $(ZEND_EXT_TYPE)=$(top_builddir)/modules/$$dlname"; \ 84 | done; \ 85 | fi` 86 | PHP_DEPRECATED_DIRECTIVES_REGEX = '^(magic_quotes_(gpc|runtime|sybase)?|(zend_)?extension(_debug)?(_ts)?)[\t\ ]*=' 87 | 88 | test: all 89 | @if test ! -z "$(PHP_EXECUTABLE)" && test -x "$(PHP_EXECUTABLE)"; then \ 90 | INI_FILE=`$(PHP_EXECUTABLE) -d 'display_errors=stderr' -r 'echo php_ini_loaded_file();' 2> /dev/null`; \ 91 | if test "$$INI_FILE"; then \ 92 | $(EGREP) -h -v $(PHP_DEPRECATED_DIRECTIVES_REGEX) "$$INI_FILE" > $(top_builddir)/tmp-php.ini; \ 93 | else \ 94 | echo > $(top_builddir)/tmp-php.ini; \ 95 | fi; \ 96 | INI_SCANNED_PATH=`$(PHP_EXECUTABLE) -d 'display_errors=stderr' -r '$$a = explode(",\n", trim(php_ini_scanned_files())); echo $$a[0];' 2> /dev/null`; \ 97 | if test "$$INI_SCANNED_PATH"; then \ 98 | INI_SCANNED_PATH=`$(top_srcdir)/build/shtool path -d $$INI_SCANNED_PATH`; \ 99 | $(EGREP) -h -v $(PHP_DEPRECATED_DIRECTIVES_REGEX) "$$INI_SCANNED_PATH"/*.ini >> $(top_builddir)/tmp-php.ini; \ 100 | fi; \ 101 | TEST_PHP_EXECUTABLE=$(PHP_EXECUTABLE) \ 102 | TEST_PHP_SRCDIR=$(top_srcdir) \ 103 | CC="$(CC)" \ 104 | $(PHP_EXECUTABLE) -n -c $(top_builddir)/tmp-php.ini $(PHP_TEST_SETTINGS) $(top_srcdir)/run-tests.php -n -c $(top_builddir)/tmp-php.ini -d extension_dir=$(top_builddir)/modules/ $(PHP_TEST_SHARED_EXTENSIONS) $(TESTS); \ 105 | TEST_RESULT_EXIT_CODE=$$?; \ 106 | rm $(top_builddir)/tmp-php.ini; \ 107 | exit $$TEST_RESULT_EXIT_CODE; \ 108 | else \ 109 | echo "ERROR: Cannot run tests without CLI sapi."; \ 110 | fi 111 | 112 | clean: 113 | find . -name \*.gcno -o -name \*.gcda | xargs rm -f 114 | find . -name \*.lo -o -name \*.o | xargs rm -f 115 | find . -name \*.la -o -name \*.a | xargs rm -f 116 | find . -name \*.so | xargs rm -f 117 | find . -name .libs -a -type d|xargs rm -rf 118 | rm -f libphp$(PHP_MAJOR_VERSION).la $(SAPI_CLI_PATH) $(SAPI_CGI_PATH) $(SAPI_MILTER_PATH) $(SAPI_LITESPEED_PATH) $(SAPI_FPM_PATH) $(OVERALL_TARGET) modules/* libs/* 119 | 120 | distclean: clean 121 | rm -f Makefile config.cache config.log config.status Makefile.objects Makefile.fragments libtool main/php_config.h main/internal_functions_cli.c main/internal_functions.c stamp-h sapi/apache/libphp$(PHP_MAJOR_VERSION).module sapi/apache_hooks/libphp$(PHP_MAJOR_VERSION).module buildmk.stamp Zend/zend_dtrace_gen.h Zend/zend_dtrace_gen.h.bak Zend/zend_config.h TSRM/tsrm_config.h 122 | rm -f php5.spec main/build-defs.h scripts/phpize 123 | rm -f ext/date/lib/timelib_config.h ext/mbstring/oniguruma/config.h ext/mbstring/libmbfl/config.h ext/mysqlnd/php_mysqlnd_config.h 124 | rm -f scripts/man1/phpize.1 scripts/php-config scripts/man1/php-config.1 sapi/cli/php.1 sapi/cgi/php-cgi.1 ext/phar/phar.1 ext/phar/phar.phar.1 125 | rm -f sapi/fpm/php-fpm.conf sapi/fpm/init.d.php-fpm sapi/fpm/php-fpm.service sapi/fpm/php-fpm.8 sapi/fpm/status.html 126 | rm -f ext/iconv/php_have_bsd_iconv.h ext/iconv/php_have_glibc_iconv.h ext/iconv/php_have_ibm_iconv.h ext/iconv/php_have_iconv.h ext/iconv/php_have_libiconv.h ext/iconv/php_iconv_aliased_libiconv.h ext/iconv/php_iconv_supports_errno.h ext/iconv/php_php_iconv_h_path.h ext/iconv/php_php_iconv_impl.h 127 | rm -f ext/phar/phar.phar ext/phar/phar.php 128 | if test "$(srcdir)" != "$(builddir)"; then \ 129 | rm -f ext/phar/phar/phar.inc; \ 130 | fi 131 | $(EGREP) define'.*include/php' $(top_srcdir)/configure | $(SED) 's/.*>//'|xargs rm -f 132 | 133 | .PHONY: all clean install distclean test 134 | .NOEXPORT: 135 | -------------------------------------------------------------------------------- /ext/kernel/memory.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | +------------------------------------------------------------------------+ 4 | | Zephir Language | 5 | +------------------------------------------------------------------------+ 6 | | Copyright (c) 2011-2014 Zephir Team (http://www.zephir-lang.com) | 7 | +------------------------------------------------------------------------+ 8 | | This source file is subject to the New BSD License that is bundled | 9 | | with this package in the file docs/LICENSE.txt. | 10 | | | 11 | | If you did not receive a copy of the license and are unable to | 12 | | obtain it through the world-wide-web, please send an email | 13 | | to license@zephir-lang.com so we can send you a copy immediately. | 14 | +------------------------------------------------------------------------+ 15 | | Authors: Andres Gutierrez | 16 | | Eduar Carvajal | 17 | | Vladimir Kolesnikov | 18 | +------------------------------------------------------------------------+ 19 | */ 20 | 21 | #ifndef ZEPHIR_KERNEL_MEMORY_H 22 | #define ZEPHIR_KERNEL_MEMORY_H 23 | 24 | /* Variable Tracking */ 25 | void zephir_init_nvar(zval **var TSRMLS_DC); 26 | void zephir_cpy_wrt(zval **dest, zval *var TSRMLS_DC); 27 | void zephir_cpy_wrt_ctor(zval **dest, zval *var TSRMLS_DC); 28 | 29 | void zephir_value_dtor(zval *zvalue ZEND_FILE_LINE_DC); 30 | 31 | /* Memory Frames */ 32 | #ifndef ZEPHIR_RELEASE 33 | void ZEPHIR_FASTCALL zephir_memory_grow_stack(const char *func TSRMLS_DC); 34 | int ZEPHIR_FASTCALL zephir_memory_restore_stack(const char *func TSRMLS_DC); 35 | 36 | #define ZEPHIR_MM_GROW() zephir_memory_grow_stack(NULL TSRMLS_CC) 37 | #define ZEPHIR_MM_RESTORE() zephir_memory_restore_stack(NULL TSRMLS_CC) 38 | 39 | #else 40 | void ZEPHIR_FASTCALL zephir_memory_grow_stack(TSRMLS_D); 41 | int ZEPHIR_FASTCALL zephir_memory_restore_stack(TSRMLS_D); 42 | 43 | #define ZEPHIR_MM_GROW() zephir_memory_grow_stack(TSRMLS_C) 44 | #define ZEPHIR_MM_RESTORE() zephir_memory_restore_stack(TSRMLS_C) 45 | 46 | #endif 47 | 48 | void ZEPHIR_FASTCALL zephir_memory_observe(zval **var TSRMLS_DC); 49 | void ZEPHIR_FASTCALL zephir_memory_remove(zval **var TSRMLS_DC); 50 | void ZEPHIR_FASTCALL zephir_memory_alloc(zval **var TSRMLS_DC); 51 | void ZEPHIR_FASTCALL zephir_memory_alloc_pnull(zval **var TSRMLS_DC); 52 | 53 | int ZEPHIR_FASTCALL zephir_clean_restore_stack(TSRMLS_D); 54 | 55 | /* Virtual symbol tables */ 56 | void zephir_create_symbol_table(TSRMLS_D); 57 | /*void zephir_restore_symbol_table(TSRMLS_D);*/ 58 | void zephir_clean_symbol_tables(TSRMLS_D); 59 | 60 | /** Export symbols to active symbol table */ 61 | int zephir_set_symbol(zval *key_name, zval *value TSRMLS_DC); 62 | int zephir_set_symbol_str(char *key_name, unsigned int key_length, zval *value TSRMLS_DC); 63 | 64 | void ZEPHIR_FASTCALL zephir_copy_ctor(zval *destiny, zval *origin); 65 | 66 | /* Memory macros */ 67 | #define ZEPHIR_ALLOC_ZVAL(z) \ 68 | ALLOC_INIT_ZVAL(z) 69 | 70 | #define ZEPHIR_SINIT_VAR(z) \ 71 | INIT_PZVAL(&z); \ 72 | ZVAL_NULL(&z); 73 | 74 | #define ZEPHIR_SINIT_NVAR(z) Z_SET_REFCOUNT_P(&z, 1) 75 | 76 | #define ZEPHIR_INIT_ZVAL_NREF(z) \ 77 | ALLOC_ZVAL(z); \ 78 | Z_SET_REFCOUNT_P(z, 0); \ 79 | Z_UNSET_ISREF_P(z); 80 | 81 | #define ZEPHIR_INIT_VAR(z) \ 82 | zephir_memory_alloc(&z TSRMLS_CC) 83 | 84 | #define ZEPHIR_INIT_NVAR(z)\ 85 | if (z) { \ 86 | if (Z_REFCOUNT_P(z) > 1) { \ 87 | Z_DELREF_P(z); \ 88 | ALLOC_ZVAL(z); \ 89 | Z_SET_REFCOUNT_P(z, 1); \ 90 | Z_UNSET_ISREF_P(z); \ 91 | } else {\ 92 | zval_dtor(z); \ 93 | } \ 94 | ZVAL_NULL(z); \ 95 | } else { \ 96 | zephir_memory_alloc(&z TSRMLS_CC); \ 97 | } 98 | 99 | /** 100 | * Second allocation, assumes the variable was allocated for the first time in the branch zero 101 | */ 102 | #define ZEPHIR_INIT_BNVAR(z) \ 103 | if (Z_REFCOUNT_P(z) > 1) { \ 104 | Z_DELREF_P(z); \ 105 | ALLOC_ZVAL(z); \ 106 | Z_SET_REFCOUNT_P(z, 1); \ 107 | Z_UNSET_ISREF_P(z); \ 108 | ZVAL_NULL(z); \ 109 | } else {\ 110 | zval_ptr_dtor(&z); \ 111 | ZEPHIR_ALLOC_ZVAL(z); \ 112 | } 113 | 114 | #define ZEPHIR_INIT_NVAR_PNULL(z)\ 115 | if (z) { \ 116 | if (Z_REFCOUNT_P(z) > 1) { \ 117 | Z_DELREF_P(z); \ 118 | if (Z_REFCOUNT_P(z) >= 1) { \ 119 | zval_copy_ctor(z); \ 120 | } \ 121 | ALLOC_ZVAL(z); \ 122 | Z_SET_REFCOUNT_P(z, 1); \ 123 | Z_UNSET_ISREF_P(z); \ 124 | } \ 125 | ZVAL_NULL(z); \ 126 | } else { \ 127 | zephir_memory_alloc_pnull(&z TSRMLS_CC); \ 128 | } 129 | 130 | /* only removes the value body of the zval */ 131 | #define ZEPHIR_INIT_LNVAR(z)\ 132 | if (z) { \ 133 | if (Z_REFCOUNT_P(z) > 1) { \ 134 | Z_DELREF_P(z); \ 135 | ALLOC_ZVAL(z); \ 136 | Z_SET_REFCOUNT_P(z, 1); \ 137 | Z_UNSET_ISREF_P(z); \ 138 | ZVAL_NULL(z); \ 139 | } else {\ 140 | zephir_value_dtor(z ZEND_FILE_LINE_CC); \ 141 | ZVAL_NULL(z); \ 142 | } \ 143 | } else { \ 144 | zephir_memory_alloc(&z TSRMLS_CC); \ 145 | } 146 | 147 | #define ZEPHIR_CPY_WRT(d, v) \ 148 | if (d) { \ 149 | if (Z_REFCOUNT_P(d) > 0) { \ 150 | zval_ptr_dtor(&d); \ 151 | } \ 152 | } else { \ 153 | zephir_memory_observe(&d TSRMLS_CC); \ 154 | } \ 155 | Z_ADDREF_P(v); \ 156 | d = v; 157 | 158 | #define ZEPHIR_CPY_WRT_CTOR(d, v) \ 159 | if (d) { \ 160 | if (Z_REFCOUNT_P(d) > 0) { \ 161 | zval_ptr_dtor(&d); \ 162 | } \ 163 | } else { \ 164 | zephir_memory_observe(&d TSRMLS_CC); \ 165 | } \ 166 | ALLOC_ZVAL(d); \ 167 | *d = *v; \ 168 | zval_copy_ctor(d); \ 169 | Z_SET_REFCOUNT_P(d, 1); \ 170 | Z_UNSET_ISREF_P(d); 171 | 172 | /* */ 173 | #define ZEPHIR_OBS_VAR(z) \ 174 | zephir_memory_observe(&z TSRMLS_CC) 175 | 176 | #define ZEPHIR_OBS_NVAR(z)\ 177 | if (z) { \ 178 | if (Z_REFCOUNT_P(z) > 1) { \ 179 | Z_DELREF_P(z); \ 180 | } else {\ 181 | zval_ptr_dtor(&z); \ 182 | z = NULL; \ 183 | } \ 184 | } else { \ 185 | zephir_memory_observe(&z TSRMLS_CC); \ 186 | } 187 | 188 | #define ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(ppzv) \ 189 | do { \ 190 | zval **tmp_ = (ppzv); \ 191 | if (tmp_ != NULL) { \ 192 | if (*tmp_) { \ 193 | zval_ptr_dtor(tmp_); \ 194 | *tmp_ = NULL; \ 195 | } \ 196 | else { \ 197 | zephir_memory_observe((ppzv) TSRMLS_CC); \ 198 | } \ 199 | } \ 200 | } while (0) 201 | 202 | #define ZEPHIR_OBSERVE_OR_NULLIFY_VAR(z) \ 203 | do { \ 204 | if (z) { \ 205 | zval_ptr_dtor(&z); \ 206 | z = NULL; \ 207 | } \ 208 | else { \ 209 | zephir_memory_observe(&z TSRMLS_CC); \ 210 | } \ 211 | } while (0) 212 | 213 | #define ZEPHIR_SEPARATE_ARRAY(a) \ 214 | { \ 215 | if (Z_REFCOUNT_P(a) > 1) { \ 216 | zval *new_zv; \ 217 | Z_DELREF_P(a); \ 218 | ALLOC_ZVAL(new_zv); \ 219 | INIT_PZVAL_COPY(new_zv, a); \ 220 | a = new_zv; \ 221 | zval_copy_ctor(new_zv); \ 222 | } \ 223 | } 224 | 225 | #define ZEPHIR_SEPARATE(z) SEPARATE_ZVAL(&z) 226 | 227 | #define ZEPHIR_SEPARATE_PARAM(z) \ 228 | do { \ 229 | zval *orig_ptr = z;\ 230 | zephir_memory_observe(&z TSRMLS_CC);\ 231 | ALLOC_ZVAL(z);\ 232 | *z = *orig_ptr;\ 233 | zval_copy_ctor(z);\ 234 | Z_SET_REFCOUNT_P(z, 1);\ 235 | Z_UNSET_ISREF_P(z);\ 236 | } while (0) 237 | 238 | #define ZEPHIR_SEPARATE_PARAM_NMO(z) { \ 239 | zval *orig_ptr = z; \ 240 | if (Z_REFCOUNT_P(orig_ptr) > 1) { \ 241 | ALLOC_ZVAL(z); \ 242 | *z = *orig_ptr; \ 243 | zval_copy_ctor(z); \ 244 | Z_SET_REFCOUNT_P(z, 1); \ 245 | Z_UNSET_ISREF_P(z); \ 246 | } \ 247 | } 248 | 249 | #endif 250 | -------------------------------------------------------------------------------- /ext/jalali.c: -------------------------------------------------------------------------------- 1 | 2 | /* This file was generated automatically by Zephir do not modify it! */ 3 | 4 | #ifdef HAVE_CONFIG_H 5 | #include "config.h" 6 | #endif 7 | 8 | #include 9 | 10 | #if PHP_VERSION_ID < 50500 11 | #include 12 | #endif 13 | 14 | #include "php_ext.h" 15 | #include "jalali.h" 16 | 17 | #include 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | #include "kernel/main.h" 24 | #include "kernel/fcall.h" 25 | #include "kernel/memory.h" 26 | 27 | zend_class_entry *jalali_date_ce; 28 | 29 | ZEND_DECLARE_MODULE_GLOBALS(jalali) 30 | 31 | #define ZEPHIR_NUM_PREALLOCATED_FRAMES 25 32 | 33 | void zephir_initialize_memory(zend_zephir_globals_def *zephir_globals_ptr TSRMLS_DC) 34 | { 35 | zephir_memory_entry *start; 36 | size_t i; 37 | 38 | start = (zephir_memory_entry *) pecalloc(ZEPHIR_NUM_PREALLOCATED_FRAMES, sizeof(zephir_memory_entry), 1); 39 | /* pecalloc() will take care of these members for every frame 40 | start->pointer = 0; 41 | start->hash_pointer = 0; 42 | start->prev = NULL; 43 | start->next = NULL; 44 | */ 45 | for (i = 0; i < ZEPHIR_NUM_PREALLOCATED_FRAMES; ++i) { 46 | start[i].addresses = pecalloc(24, sizeof(zval*), 1); 47 | start[i].capacity = 24; 48 | start[i].hash_addresses = pecalloc(8, sizeof(zval*), 1); 49 | start[i].hash_capacity = 8; 50 | 51 | #ifndef ZEPHIR_RELEASE 52 | start[i].permanent = 1; 53 | #endif 54 | } 55 | 56 | start[0].next = &start[1]; 57 | start[ZEPHIR_NUM_PREALLOCATED_FRAMES - 1].prev = &start[ZEPHIR_NUM_PREALLOCATED_FRAMES - 2]; 58 | 59 | for (i = 1; i < ZEPHIR_NUM_PREALLOCATED_FRAMES - 1; ++i) { 60 | start[i].next = &start[i + 1]; 61 | start[i].prev = &start[i - 1]; 62 | } 63 | 64 | zephir_globals_ptr->start_memory = start; 65 | zephir_globals_ptr->end_memory = start + ZEPHIR_NUM_PREALLOCATED_FRAMES; 66 | 67 | zephir_globals_ptr->fcache = pemalloc(sizeof(HashTable), 1); 68 | zend_hash_init(zephir_globals_ptr->fcache, 128, NULL, NULL, 1); // zephir_fcall_cache_dtor 69 | 70 | /* 'Allocator sizeof operand mismatch' warning can be safely ignored */ 71 | ALLOC_INIT_ZVAL(zephir_globals_ptr->global_null); 72 | Z_SET_REFCOUNT_P(zephir_globals_ptr->global_null, 2); 73 | 74 | /* 'Allocator sizeof operand mismatch' warning can be safely ignored */ 75 | ALLOC_INIT_ZVAL(zephir_globals_ptr->global_false); 76 | Z_SET_REFCOUNT_P(zephir_globals_ptr->global_false, 2); 77 | ZVAL_FALSE(zephir_globals_ptr->global_false); 78 | 79 | /* 'Allocator sizeof operand mismatch' warning can be safely ignored */ 80 | ALLOC_INIT_ZVAL(zephir_globals_ptr->global_true); 81 | Z_SET_REFCOUNT_P(zephir_globals_ptr->global_true, 2); 82 | ZVAL_TRUE(zephir_globals_ptr->global_true); 83 | 84 | //zephir_globals_ptr->initialized = 1; 85 | } 86 | 87 | int zephir_cleanup_fcache(void *pDest TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) 88 | { 89 | zephir_fcall_cache_entry **entry = (zephir_fcall_cache_entry**)pDest; 90 | zend_class_entry *scope; 91 | uint len = hash_key->nKeyLength; 92 | 93 | assert(hash_key->arKey != NULL); 94 | assert(hash_key->nKeyLength > 2 * sizeof(zend_class_entry**)); 95 | 96 | memcpy(&scope, &hash_key->arKey[len - 2 * sizeof(zend_class_entry**)], sizeof(zend_class_entry*)); 97 | 98 | /* 99 | #ifndef ZEPHIR_RELEASE 100 | { 101 | zend_class_entry *cls; 102 | memcpy(&cls, &hash_key->arKey[len - sizeof(zend_class_entry**)], sizeof(zend_class_entry*)); 103 | 104 | fprintf(stderr, "func: %s, cls: %s, scope: %s [%u]\n", (*entry)->f->common.function_name, (cls ? cls->name : "N/A"), (scope ? scope->name : "N/A"), (uint)(*entry)->times); 105 | } 106 | #endif 107 | */ 108 | 109 | #ifndef ZEPHIR_RELEASE 110 | if ((*entry)->f->type != ZEND_INTERNAL_FUNCTION || (scope && scope->type != ZEND_INTERNAL_CLASS)) { 111 | return ZEND_HASH_APPLY_REMOVE; 112 | } 113 | #else 114 | if ((*entry)->type != ZEND_INTERNAL_FUNCTION || (scope && scope->type != ZEND_INTERNAL_CLASS)) { 115 | return ZEND_HASH_APPLY_REMOVE; 116 | } 117 | #endif 118 | 119 | #if PHP_VERSION_ID >= 50400 120 | if (scope && scope->type == ZEND_INTERNAL_CLASS && scope->info.internal.module->type != MODULE_PERSISTENT) { 121 | return ZEND_HASH_APPLY_REMOVE; 122 | } 123 | #else 124 | if (scope && scope->type == ZEND_INTERNAL_CLASS && scope->module->type != MODULE_PERSISTENT) { 125 | return ZEND_HASH_APPLY_REMOVE; 126 | } 127 | #endif 128 | 129 | return ZEND_HASH_APPLY_KEEP; 130 | } 131 | 132 | void zephir_deinitialize_memory(TSRMLS_D) 133 | { 134 | size_t i; 135 | zend_zephir_globals_def *zephir_globals_ptr = ZEPHIR_VGLOBAL; 136 | 137 | //if (zephir_globals_ptr->initialized != 1) { 138 | // zephir_globals_ptr->initialized = 0; 139 | // return; 140 | //} 141 | 142 | if (zephir_globals_ptr->start_memory != NULL) { 143 | zephir_clean_restore_stack(TSRMLS_C); 144 | } 145 | 146 | //zephir_orm_destroy_cache(TSRMLS_C); 147 | 148 | zend_hash_apply_with_arguments(zephir_globals_ptr->fcache TSRMLS_CC, zephir_cleanup_fcache, 0); 149 | 150 | #ifndef ZEPHIR_RELEASE 151 | assert(zephir_globals_ptr->start_memory != NULL); 152 | #endif 153 | 154 | for (i = 0; i < ZEPHIR_NUM_PREALLOCATED_FRAMES; ++i) { 155 | pefree(zephir_globals_ptr->start_memory[i].hash_addresses, 1); 156 | pefree(zephir_globals_ptr->start_memory[i].addresses, 1); 157 | } 158 | 159 | pefree(zephir_globals_ptr->start_memory, 1); 160 | zephir_globals_ptr->start_memory = NULL; 161 | 162 | zend_hash_destroy(zephir_globals_ptr->fcache); 163 | pefree(zephir_globals_ptr->fcache, 1); 164 | zephir_globals_ptr->fcache = NULL; 165 | 166 | for (i = 0; i < 2; i++) { 167 | zval_ptr_dtor(&zephir_globals_ptr->global_null); 168 | zval_ptr_dtor(&zephir_globals_ptr->global_false); 169 | zval_ptr_dtor(&zephir_globals_ptr->global_true); 170 | } 171 | 172 | //zephir_globals_ptr->initialized = 0; 173 | } 174 | 175 | static PHP_MINIT_FUNCTION(jalali) 176 | { 177 | #if PHP_VERSION_ID < 50500 178 | char* old_lc_all = setlocale(LC_ALL, NULL); 179 | if (old_lc_all) { 180 | size_t len = strlen(old_lc_all); 181 | char *tmp = calloc(len+1, 1); 182 | if (UNEXPECTED(!tmp)) { 183 | return FAILURE; 184 | } 185 | 186 | memcpy(tmp, old_lc_all, len); 187 | old_lc_all = tmp; 188 | } 189 | 190 | setlocale(LC_ALL, "C"); 191 | #endif 192 | 193 | ZEPHIR_INIT(Jalali_Date); 194 | 195 | #if PHP_VERSION_ID < 50500 196 | setlocale(LC_ALL, old_lc_all); 197 | free(old_lc_all); 198 | #endif 199 | return SUCCESS; 200 | } 201 | 202 | #ifndef ZEPHIR_RELEASE 203 | static PHP_MSHUTDOWN_FUNCTION(jalali) 204 | { 205 | 206 | zephir_deinitialize_memory(TSRMLS_C); 207 | 208 | //assert(ZEPHIR_GLOBAL(orm).parser_cache == NULL); 209 | //assert(ZEPHIR_GLOBAL(orm).ast_cache == NULL); 210 | 211 | return SUCCESS; 212 | } 213 | #endif 214 | 215 | /** 216 | * Initialize globals on each request or each thread started 217 | */ 218 | static void php_zephir_init_globals(zend_jalali_globals *zephir_globals TSRMLS_DC) 219 | { 220 | 221 | /* Memory options */ 222 | zephir_globals->active_memory = NULL; 223 | 224 | /* Virtual Symbol Tables */ 225 | zephir_globals->active_symbol_table = NULL; 226 | 227 | /* Recursive Lock */ 228 | zephir_globals->recursive_lock = 0; 229 | 230 | 231 | } 232 | 233 | static PHP_RINIT_FUNCTION(jalali) 234 | { 235 | 236 | zend_jalali_globals *zephir_globals_ptr = ZEPHIR_VGLOBAL; 237 | 238 | php_zephir_init_globals(zephir_globals_ptr TSRMLS_CC); 239 | //zephir_init_interned_strings(TSRMLS_C); 240 | 241 | zephir_initialize_memory(zephir_globals_ptr TSRMLS_CC); 242 | 243 | return SUCCESS; 244 | } 245 | 246 | static PHP_RSHUTDOWN_FUNCTION(jalali) 247 | { 248 | 249 | zephir_deinitialize_memory(TSRMLS_C); 250 | return SUCCESS; 251 | } 252 | 253 | static PHP_MINFO_FUNCTION(jalali) 254 | { 255 | php_info_print_box_start(0); 256 | php_printf("%s", PHP_JALALI_DESCRIPTION); 257 | php_info_print_box_end(); 258 | 259 | php_info_print_table_start(); 260 | php_info_print_table_header(2, PHP_JALALI_NAME, "enabled"); 261 | php_info_print_table_row(2, "Author", PHP_JALALI_AUTHOR); 262 | php_info_print_table_row(2, "Version", PHP_JALALI_VERSION); 263 | php_info_print_table_row(2, "Powered by Zephir", "Version " PHP_JALALI_ZEPVERSION); 264 | php_info_print_table_end(); 265 | 266 | 267 | } 268 | 269 | static PHP_GINIT_FUNCTION(jalali) 270 | { 271 | php_zephir_init_globals(jalali_globals TSRMLS_CC); 272 | } 273 | 274 | static PHP_GSHUTDOWN_FUNCTION(jalali) 275 | { 276 | 277 | } 278 | 279 | zend_module_entry jalali_module_entry = { 280 | STANDARD_MODULE_HEADER_EX, 281 | NULL, 282 | NULL, 283 | PHP_JALALI_EXTNAME, 284 | NULL, 285 | PHP_MINIT(jalali), 286 | #ifndef ZEPHIR_RELEASE 287 | PHP_MSHUTDOWN(jalali), 288 | #else 289 | NULL, 290 | #endif 291 | PHP_RINIT(jalali), 292 | PHP_RSHUTDOWN(jalali), 293 | PHP_MINFO(jalali), 294 | PHP_JALALI_VERSION, 295 | ZEND_MODULE_GLOBALS(jalali), 296 | PHP_GINIT(jalali), 297 | PHP_GSHUTDOWN(jalali), 298 | NULL, 299 | STANDARD_MODULE_PROPERTIES_EX 300 | }; 301 | 302 | #ifdef COMPILE_DL_JALALI 303 | ZEND_GET_MODULE(jalali) 304 | #endif 305 | -------------------------------------------------------------------------------- /ext/kernel/debug.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | +------------------------------------------------------------------------+ 4 | | Zephir Language | 5 | +------------------------------------------------------------------------+ 6 | | Copyright (c) 2011-2014 Zephir Team (http://www.zephir-lang.com) | 7 | +------------------------------------------------------------------------+ 8 | | This source file is subject to the New BSD License that is bundled | 9 | | with this package in the file docs/LICENSE.txt. | 10 | | | 11 | | If you did not receive a copy of the license and are unable to | 12 | | obtain it through the world-wide-web, please send an email | 13 | | to license@zephir-lang.com so we can send you a copy immediately. | 14 | +------------------------------------------------------------------------+ 15 | | Authors: Andres Gutierrez | 16 | | Eduar Carvajal | 17 | +------------------------------------------------------------------------+ 18 | */ 19 | 20 | #ifdef HAVE_CONFIG_H 21 | #include "config.h" 22 | #endif 23 | 24 | #include 25 | #include "php_ext.h" 26 | #include "kernel/debug.h" 27 | #include "kernel/main.h" 28 | #include "kernel/string.h" 29 | 30 | #ifndef ZEPHIR_RELEASE 31 | 32 | FILE *zephir_log = NULL; 33 | int zephir_debug_trace = 0; 34 | static zephir_debug_entry *start = NULL; 35 | static zephir_debug_entry *active = NULL; 36 | 37 | /** 38 | * Stars debug on file pipe 39 | */ 40 | int zephir_start_debug(){ 41 | if(!zephir_log){ 42 | /*//zephir_log = fopen("/home/gutierrezandresfelipe/phalcon-debug.a", "w"); 43 | zephir_log = fopen("/tmp/phalcon-debug.a", "w"); 44 | if(!zephir_log){ 45 | fprintf(stderr, "Can't open debug log\n"); 46 | }*/ 47 | zephir_log = stderr; 48 | } 49 | return SUCCESS; 50 | } 51 | 52 | /** 53 | * Stops debug process 54 | */ 55 | int zephir_stop_debug(){ 56 | zephir_debug_entry *ptr = active; 57 | zephir_debug_entry *this_entry = NULL; 58 | while(ptr){ 59 | this_entry = ptr; 60 | ptr = ptr->prev; 61 | efree(this_entry); 62 | } 63 | //fclose(zephir_log); 64 | zephir_log = NULL; 65 | return SUCCESS; 66 | } 67 | 68 | /** 69 | * Executes a print_r on an interal zval 70 | */ 71 | int zephir_print_r(zval *userval TSRMLS_DC){ 72 | zend_print_zval_r(userval, 0 TSRMLS_CC); 73 | return SUCCESS; 74 | } 75 | 76 | /** 77 | * Internal fast zval dump 78 | */ 79 | int zephir_vdump(zval *uservar TSRMLS_DC){ 80 | zephir_start_debug(); 81 | if(!uservar){ 82 | fprintf(zephir_log, "Null pointer\n"); 83 | return SUCCESS; 84 | } 85 | switch(Z_TYPE_P(uservar)){ 86 | case IS_NULL: 87 | fprintf(zephir_log, "NULL \n"); 88 | break; 89 | case IS_BOOL: 90 | fprintf(zephir_log, "Boolean: %s\n", Z_LVAL_P(uservar) ? "TRUE" : "FALSE"); 91 | break; 92 | case IS_LONG: 93 | fprintf(zephir_log, "Long: %ld at %p, refcount=%d\n", Z_LVAL_P(uservar), uservar, Z_REFCOUNT_P(uservar)); 94 | break; 95 | case IS_DOUBLE: 96 | fprintf(zephir_log, "Double: %f\n", Z_DVAL_P(uservar)); 97 | break; 98 | case IS_STRING: 99 | fprintf(zephir_log, "String: %s(%d) at %p, refcount=%d\n", Z_STRVAL_P(uservar), Z_STRLEN_P(uservar), uservar, Z_REFCOUNT_P(uservar)); 100 | break; 101 | case IS_RESOURCE: 102 | fprintf(zephir_log, "Resource\n"); 103 | break; 104 | case IS_ARRAY: 105 | fprintf(zephir_log, "Array at %p, refcount=%d\n", uservar, Z_REFCOUNT_P(uservar)); 106 | break; 107 | case IS_OBJECT: 108 | fprintf(zephir_log, "Object <%s> at %p\n", Z_OBJCE_P(uservar)->name, uservar); 109 | break; 110 | default: 111 | fprintf(zephir_log, "Unknown\n"); 112 | } 113 | return SUCCESS; 114 | } 115 | 116 | int zephir_dump_ce(zend_class_entry *ce TSRMLS_DC){ 117 | char *message = emalloc(sizeof(char *)*120); 118 | if(ce){ 119 | sprintf(message, "- ClassType => %d", ce->type); 120 | zephir_step_over(message); 121 | if(ce->name){ 122 | sprintf(message, "- ClassName => %s", ce->name); 123 | zephir_step_over(message); 124 | } else { 125 | zephir_step_over("- ClassName => NULL"); 126 | } 127 | } else { 128 | zephir_step_over("- NULL class entry :("); 129 | } 130 | return SUCCESS; 131 | } 132 | 133 | int zephir_class_debug(zval *val TSRMLS_DC){ 134 | char *message = emalloc(sizeof(char *)*120); 135 | zend_class_entry *ce; 136 | if(val){ 137 | ce = Z_OBJCE_P(val); 138 | if(ce){ 139 | sprintf(message, "- MemoryAddress => %p", val); 140 | zephir_step_over(message); 141 | zephir_dump_ce(ce TSRMLS_CC); 142 | } else { 143 | zephir_step_over("- No class entry :("); 144 | } 145 | } else { 146 | zephir_step_over("- this_ptr is null :("); 147 | } 148 | return SUCCESS; 149 | } 150 | 151 | /** 152 | * Append debug information to file 153 | */ 154 | int zephir_debug_str(char *what, char *message){ 155 | fprintf(zephir_log, "%s", what); 156 | fprintf(zephir_log, "%s", message); 157 | fprintf(zephir_log, "\n"); 158 | return SUCCESS; 159 | } 160 | 161 | int zephir_debug_long(char *what, uint vlong){ 162 | fprintf(zephir_log, "%s", what); 163 | fprintf(zephir_log, "%u", vlong); 164 | fprintf(zephir_log, "\n"); 165 | return SUCCESS; 166 | } 167 | 168 | int zephir_debug_screen(char *message){ 169 | zephir_debug_space(); 170 | fprintf(zephir_log, "%s\n", message); 171 | return SUCCESS; 172 | } 173 | 174 | int zephir_debug_method_call(zval *obj, char *method_name TSRMLS_DC){ 175 | if(Z_TYPE_P(obj)==IS_OBJECT){ 176 | zephir_debug_space(); 177 | } else { 178 | zephir_error_space(); 179 | } 180 | if(Z_TYPE_P(obj)==IS_OBJECT){ 181 | fprintf(zephir_log, "Calling method %s::%s on Object at %p\n", Z_OBJCE_P(obj)->name, method_name, obj); 182 | } else { 183 | fprintf(zephir_log, "Calling method %s on non object :(\n", method_name); 184 | } 185 | return SUCCESS; 186 | } 187 | 188 | int zephir_error_space(){ 189 | int i; 190 | fprintf(zephir_log, "[ERROR] "); 191 | for(i=0;i "); 209 | zephir_vdump(param TSRMLS_CC); 210 | return SUCCESS; 211 | } 212 | 213 | int zephir_debug_vdump(char *preffix, zval *value TSRMLS_DC){ 214 | zephir_debug_space(); 215 | fprintf(zephir_log, "%s", preffix); 216 | zephir_vdump(value TSRMLS_CC); 217 | return SUCCESS; 218 | } 219 | 220 | int zephir_debug_assign(char *name, zval *value TSRMLS_DC){ 221 | zephir_debug_space(); 222 | fprintf(zephir_log, "Assign on %s with ", name); 223 | zephir_vdump(value TSRMLS_CC); 224 | return SUCCESS; 225 | } 226 | 227 | int zephir_step_over(char *message){ 228 | zephir_debug_screen(message); 229 | return SUCCESS; 230 | } 231 | 232 | int zephir_step_into(char *message){ 233 | zephir_debug_trace++; 234 | zephir_debug_screen(message); 235 | return SUCCESS; 236 | } 237 | 238 | int zephir_step_out(char *message){ 239 | zephir_debug_screen(message); 240 | zephir_debug_trace--; 241 | return SUCCESS; 242 | } 243 | 244 | /** 245 | * Prints internal debug backtrace 246 | */ 247 | int zephir_debug_backtrace_internal(){ 248 | int step = 0; 249 | char *message; 250 | zephir_debug_entry *ptr = active; 251 | while(ptr){ 252 | zephir_spprintf(&message, 0, "#%d %s::%s", step, ptr->class_name, ptr->method_name); 253 | zephir_debug_screen(message); 254 | efree(message); 255 | ptr = ptr->prev; 256 | step++; 257 | } 258 | return SUCCESS; 259 | } 260 | 261 | /** 262 | * Appends a debug entry to internal execution scope 263 | */ 264 | int zephir_step_into_entry(char *class_name, char *method_name, int lineno){ 265 | 266 | char *message; 267 | zephir_debug_entry *entry; 268 | 269 | if (!start) { 270 | start = (zephir_debug_entry *) emalloc(sizeof(zephir_debug_entry)); 271 | start->class_name = "__main__"; 272 | start->method_name = "__init__"; 273 | start->lineno = 0; 274 | start->prev = NULL; 275 | start->next = NULL; 276 | active = start; 277 | } 278 | 279 | zephir_spprintf(&message, 0, "Step Into %s::%s", class_name, method_name); 280 | zephir_debug_screen(message); 281 | efree(message); 282 | 283 | entry = emalloc(sizeof(zephir_debug_entry)); 284 | entry->class_name = class_name; 285 | entry->method_name = method_name; 286 | entry->lineno = lineno; 287 | entry->prev = active; 288 | active->next = entry; 289 | active = entry; 290 | zephir_debug_trace++; 291 | 292 | return SUCCESS; 293 | } 294 | 295 | /** 296 | * Steps out current stack 297 | */ 298 | int zephir_step_out_entry(){ 299 | 300 | char *message; 301 | zephir_debug_entry *prev; 302 | if(active){ 303 | 304 | zephir_debug_trace--; 305 | 306 | zephir_spprintf(&message, 0, "Step out %s::%s", active->class_name, active->method_name); 307 | zephir_debug_screen(message); 308 | efree(message); 309 | 310 | prev = active->prev; 311 | efree(active); 312 | active = prev; 313 | 314 | } else { 315 | fprintf(zephir_log, "Problem, stack?"); 316 | return FAILURE; 317 | } 318 | return SUCCESS; 319 | } 320 | 321 | #endif 322 | -------------------------------------------------------------------------------- /ext/kernel/filter.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | +------------------------------------------------------------------------+ 4 | | Zephir Language | 5 | +------------------------------------------------------------------------+ 6 | | Copyright (c) 2011-2014 Zephir Team (http://www.zephir-lang.com) | 7 | +------------------------------------------------------------------------+ 8 | | This source file is subject to the New BSD License that is bundled | 9 | | with this package in the file docs/LICENSE.txt. | 10 | | | 11 | | If you did not receive a copy of the license and are unable to | 12 | | obtain it through the world-wide-web, please send an email | 13 | | to license@zephir-lang.com so we can send you a copy immediately. | 14 | +------------------------------------------------------------------------+ 15 | | Authors: Andres Gutierrez | 16 | | Eduar Carvajal | 17 | +------------------------------------------------------------------------+ 18 | */ 19 | 20 | #ifdef HAVE_CONFIG_H 21 | #include "config.h" 22 | #endif 23 | 24 | #include 25 | 26 | #include "php.h" 27 | #include "php_ext.h" 28 | #include "php_main.h" 29 | #include "ext/standard/php_smart_str.h" 30 | #include "ext/standard/php_math.h" 31 | #include "ext/standard/html.h" 32 | 33 | #include "kernel/main.h" 34 | #include "kernel/memory.h" 35 | 36 | #include "Zend/zend_exceptions.h" 37 | #include "Zend/zend_interfaces.h" 38 | 39 | /** 40 | * Filter alphanum string 41 | */ 42 | void zephir_filter_alphanum(zval *return_value, zval *param) { 43 | 44 | unsigned int i; 45 | unsigned char ch; 46 | smart_str filtered_str = {0}; 47 | zval copy; 48 | int use_copy = 0; 49 | 50 | if (Z_TYPE_P(param) != IS_STRING) { 51 | zend_make_printable_zval(param, ©, &use_copy); 52 | if (use_copy) { 53 | param = © 54 | } 55 | } 56 | 57 | for (i = 0; i < Z_STRLEN_P(param); i++) { 58 | ch = Z_STRVAL_P(param)[i]; 59 | if (ch == '\0') { 60 | break; 61 | } 62 | if (isalnum(ch)) { 63 | smart_str_appendc(&filtered_str, ch); 64 | } 65 | } 66 | 67 | if (use_copy) { 68 | zval_dtor(param); 69 | } 70 | 71 | smart_str_0(&filtered_str); 72 | 73 | if (filtered_str.c) { 74 | RETURN_STRINGL(filtered_str.c, filtered_str.len, 0); 75 | } else { 76 | RETURN_EMPTY_STRING(); 77 | } 78 | } 79 | 80 | /** 81 | * Filter identifiers string like variables or database columns/tables 82 | */ 83 | void zephir_filter_identifier(zval *return_value, zval *param){ 84 | 85 | unsigned int i; 86 | unsigned char ch; 87 | zval copy; 88 | smart_str filtered_str = {0}; 89 | int use_copy = 0; 90 | 91 | if (Z_TYPE_P(param) != IS_STRING) { 92 | zend_make_printable_zval(param, ©, &use_copy); 93 | if (use_copy) { 94 | param = © 95 | } 96 | } 97 | 98 | for (i = 0; i < Z_STRLEN_P(param); i++) { 99 | ch = Z_STRVAL_P(param)[i]; 100 | if (ch == '\0') { 101 | break; 102 | } 103 | if (isalnum(ch) || ch == '_') { 104 | smart_str_appendc(&filtered_str, ch); 105 | } 106 | } 107 | 108 | if (use_copy) { 109 | zval_dtor(param); 110 | } 111 | 112 | smart_str_0(&filtered_str); 113 | 114 | if (filtered_str.c) { 115 | RETURN_STRINGL(filtered_str.c, filtered_str.len, 0); 116 | } else { 117 | RETURN_EMPTY_STRING(); 118 | } 119 | 120 | } 121 | 122 | /** 123 | * Check if a string is encoded with ASCII or ISO-8859-1 124 | */ 125 | void zephir_is_basic_charset(zval *return_value, const zval *param){ 126 | 127 | unsigned int i; 128 | unsigned int ch; 129 | int iso88591 = 0; 130 | 131 | for (i = 0; i < Z_STRLEN_P(param); i++) { 132 | ch = Z_STRVAL_P(param)[i]; 133 | if (ch != '\0') { 134 | if (ch == 172 || (ch >= 128 && ch <= 159)) { 135 | continue; 136 | } 137 | if (ch >= 160 && ch <= 255) { 138 | iso88591 = 1; 139 | continue; 140 | } 141 | } 142 | RETURN_FALSE; 143 | } 144 | 145 | if (!iso88591) { 146 | RETURN_STRING("ASCII", 1); 147 | } 148 | 149 | RETURN_STRING("ISO-8859-1", 1); 150 | } 151 | 152 | static long zephir_unpack(char *data, int size, int issigned, int *map) 153 | { 154 | long result; 155 | char *cresult = (char *) &result; 156 | int i; 157 | 158 | result = issigned ? -1 : 0; 159 | 160 | for (i = 0; i < size; i++) { 161 | cresult[map[i]] = *data++; 162 | } 163 | 164 | return result; 165 | } 166 | 167 | /** 168 | * Converts an unsigned long to a char* 169 | */ 170 | static inline char *zephir_longtohex(unsigned long value) { 171 | 172 | static char digits[] = "0123456789abcdef"; 173 | char buf[(sizeof(unsigned long) << 3) + 1]; 174 | char *ptr, *end; 175 | 176 | end = ptr = buf + sizeof(buf) - 1; 177 | *ptr = '\0'; 178 | do { 179 | *--ptr = digits[value & 0x0F]; 180 | value >>= 4; 181 | } while (ptr > buf && value); 182 | 183 | return estrndup(ptr, end - ptr); 184 | } 185 | 186 | /** 187 | * Perform escaping of non-alphanumeric characters to different formats 188 | */ 189 | void zephir_escape_multi(zval *return_value, zval *param, const char *escape_char, unsigned int escape_length, char escape_extra, int use_whitelist) { 190 | 191 | unsigned int i; 192 | zval copy; 193 | smart_str escaped_str = {0}; 194 | char machine_little_endian, *hex; 195 | int big_endian_long_map[4]; 196 | int use_copy = 0, machine_endian_check = 1; 197 | int issigned = 0; 198 | long value; 199 | 200 | if (Z_TYPE_P(param) != IS_STRING) { 201 | zend_make_printable_zval(param, ©, &use_copy); 202 | if (use_copy) { 203 | param = © 204 | } 205 | } 206 | 207 | if (Z_STRLEN_P(param) <= 0) { 208 | RETURN_FALSE; 209 | } 210 | 211 | /** 212 | * This is how the big_ending_long_map is calculated as in 'pack' 213 | */ 214 | machine_little_endian = ((char *) &machine_endian_check)[0]; 215 | if (machine_little_endian) { 216 | big_endian_long_map[0] = 3; 217 | big_endian_long_map[1] = 2; 218 | big_endian_long_map[2] = 1; 219 | big_endian_long_map[3] = 0; 220 | } else { 221 | int size = sizeof(Z_LVAL_P(param)); 222 | big_endian_long_map[0] = size - 4; 223 | big_endian_long_map[1] = size - 3; 224 | big_endian_long_map[2] = size - 2; 225 | big_endian_long_map[3] = size - 1; 226 | } 227 | 228 | /** 229 | * The input must be a valid UTF-32 string 230 | */ 231 | if ((Z_STRLEN_P(param) % 4) != 0) { 232 | RETURN_FALSE; 233 | } 234 | 235 | for (i = 0; i < Z_STRLEN_P(param); i += 4) { 236 | 237 | issigned = Z_STRVAL_P(param)[i] & 0x80; 238 | 239 | value = 0; 240 | if (sizeof(long) > 4 && issigned) { 241 | value = ~INT_MAX; 242 | } 243 | 244 | value |= zephir_unpack(&Z_STRVAL_P(param)[i], 4, issigned, big_endian_long_map); 245 | if (sizeof(long) > 4) { 246 | value = (unsigned int) value; 247 | } 248 | 249 | /** 250 | * CSS 2.1 section 4.1.3: "It is undefined in CSS 2.1 what happens if a 251 | * style sheet does contain a character with Unicode codepoint zero." 252 | */ 253 | if (value == '\0') { 254 | RETURN_FALSE; 255 | } 256 | 257 | /** 258 | * Alphanumeric characters are not escaped 259 | */ 260 | if (value < 256 && isalnum(value)) { 261 | smart_str_appendc(&escaped_str, (unsigned char) value); 262 | continue; 263 | } 264 | 265 | /** 266 | * Chararters in the whitelist are left as they are 267 | */ 268 | if (use_whitelist) { 269 | switch (value) { 270 | case ' ': 271 | case '/': 272 | case '*': 273 | case '+': 274 | case '-': 275 | case '\t': 276 | case '\n': 277 | case '^': 278 | case '$': 279 | case '!': 280 | case '?': 281 | case '\\': 282 | case '#': 283 | case '}': 284 | case '{': 285 | case ')': 286 | case '(': 287 | case ']': 288 | case '[': 289 | case '.': 290 | case ',': 291 | case ':': 292 | case ';': 293 | case '_': 294 | case '|': 295 | smart_str_appendc(&escaped_str, (unsigned char) value); 296 | continue; 297 | } 298 | } 299 | 300 | /** 301 | * Convert character to hexadecimal 302 | */ 303 | hex = zephir_longtohex(value); 304 | 305 | /** 306 | * Append the escaped character 307 | */ 308 | smart_str_appendl(&escaped_str, escape_char, escape_length); 309 | smart_str_appendl(&escaped_str, hex, strlen(hex)); 310 | if (escape_extra != '\0') { 311 | smart_str_appendc(&escaped_str, escape_extra); 312 | } 313 | 314 | efree(hex); 315 | } 316 | 317 | if (use_copy) { 318 | zval_dtor(param); 319 | } 320 | 321 | smart_str_0(&escaped_str); 322 | 323 | if (escaped_str.c) { 324 | RETURN_STRINGL(escaped_str.c, escaped_str.len, 0); 325 | } else { 326 | RETURN_EMPTY_STRING(); 327 | } 328 | 329 | } 330 | 331 | /** 332 | * Escapes non-alphanumeric characters to \HH+space 333 | */ 334 | void zephir_escape_css(zval *return_value, zval *param) { 335 | zephir_escape_multi(return_value, param, "\\", sizeof("\\")-1, ' ', 0); 336 | } 337 | 338 | /** 339 | * Escapes non-alphanumeric characters to \xHH+ 340 | */ 341 | void zephir_escape_js(zval *return_value, zval *param) { 342 | zephir_escape_multi(return_value, param, "\\x", sizeof("\\x")-1, '\0', 1); 343 | } 344 | 345 | /** 346 | * Escapes non-alphanumeric characters to &xHH; 347 | */ 348 | void zephir_escape_htmlattr(zval *return_value, zval *param) { 349 | zephir_escape_multi(return_value, param, "&#x", sizeof("&#x")-1, ';', 1); 350 | } 351 | 352 | /** 353 | * Escapes HTML replacing special chars by entities 354 | */ 355 | void zephir_escape_html(zval *return_value, zval *str, zval *quote_style, zval *charset TSRMLS_DC) { 356 | 357 | #if PHP_VERSION_ID < 50400 358 | int length; 359 | #else 360 | size_t length; 361 | #endif 362 | 363 | char *escaped; 364 | 365 | if (Z_TYPE_P(str) != IS_STRING) { 366 | /* Nothing to escape */ 367 | RETURN_ZVAL(str, 1, 0); 368 | } 369 | 370 | if (Z_TYPE_P(quote_style) != IS_LONG) { 371 | php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid quote_style supplied for zephir_escape_html()"); 372 | RETURN_ZVAL(str, 1, 0); 373 | } 374 | 375 | if (Z_TYPE_P(charset) != IS_STRING) { 376 | php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid charset supplied for zephir_escape_html()"); 377 | RETURN_ZVAL(str, 1, 0); 378 | } 379 | 380 | escaped = php_escape_html_entities((unsigned char*) Z_STRVAL_P(str), Z_STRLEN_P(str), &length, 0, Z_LVAL_P(quote_style), Z_STRVAL_P(charset) TSRMLS_CC); 381 | 382 | RETURN_STRINGL(escaped, length, 0); 383 | } 384 | -------------------------------------------------------------------------------- /ext/kernel/hash.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | +------------------------------------------------------------------------+ 4 | | Zephir Language | 5 | +------------------------------------------------------------------------+ 6 | | Copyright (c) 2011-2014 Zephir Team (http://www.zephir-lang.com) | 7 | +------------------------------------------------------------------------+ 8 | | This source file is subject to the New BSD License that is bundled | 9 | | with this package in the file docs/LICENSE.txt. | 10 | | | 11 | | If you did not receive a copy of the license and are unable to | 12 | | obtain it through the world-wide-web, please send an email | 13 | | to license@zephir-lang.com so we can send you a copy immediately. | 14 | +------------------------------------------------------------------------+ 15 | | Authors: Andres Gutierrez | 16 | | Eduar Carvajal | 17 | | Vladimir Kolesnikov | 18 | +------------------------------------------------------------------------+ 19 | */ 20 | 21 | #ifdef HAVE_CONFIG_H 22 | #include "config.h" 23 | #endif 24 | 25 | #include "php.h" 26 | #include "php_ext.h" 27 | 28 | #include "kernel/memory.h" 29 | 30 | int zephir_hash_exists(const HashTable *ht, const char *arKey, uint nKeyLength) 31 | { 32 | ulong h; 33 | uint nIndex; 34 | Bucket *p; 35 | 36 | h = zend_inline_hash_func(arKey, nKeyLength); 37 | nIndex = h & ht->nTableMask; 38 | 39 | p = ht->arBuckets[nIndex]; 40 | while (p != NULL) { 41 | if (p->arKey == arKey || ((p->h == h) && (p->nKeyLength == nKeyLength))) { 42 | if (!memcmp(p->arKey, arKey, nKeyLength)) { 43 | return 1; 44 | } 45 | } 46 | p = p->pNext; 47 | } 48 | return 0; 49 | } 50 | 51 | int zephir_hash_quick_exists(const HashTable *ht, const char *arKey, uint nKeyLength, ulong h) 52 | { 53 | uint nIndex; 54 | Bucket *p; 55 | 56 | if (nKeyLength == 0) { 57 | return zend_hash_index_exists(ht, h); 58 | } 59 | 60 | nIndex = h & ht->nTableMask; 61 | 62 | p = ht->arBuckets[nIndex]; 63 | while (p != NULL) { 64 | if (p->arKey == arKey || ((p->h == h) && (p->nKeyLength == nKeyLength))) { 65 | if (!memcmp(p->arKey, arKey, nKeyLength)) { 66 | return 1; 67 | } 68 | } 69 | p = p->pNext; 70 | } 71 | return 0; 72 | } 73 | 74 | int zephir_hash_find(const HashTable *ht, const char *arKey, uint nKeyLength, void **pData) 75 | { 76 | ulong h; 77 | uint nIndex; 78 | Bucket *p; 79 | 80 | h = zend_inline_hash_func(arKey, nKeyLength); 81 | nIndex = h & ht->nTableMask; 82 | 83 | p = ht->arBuckets[nIndex]; 84 | while (p != NULL) { 85 | if (p->arKey == arKey || ((p->h == h) && (p->nKeyLength == nKeyLength))) { 86 | if (!memcmp(p->arKey, arKey, nKeyLength)) { 87 | *pData = p->pData; 88 | return SUCCESS; 89 | } 90 | } 91 | p = p->pNext; 92 | } 93 | return FAILURE; 94 | } 95 | 96 | int zephir_hash_quick_find(const HashTable *ht, const char *arKey, uint nKeyLength, ulong h, void **pData) 97 | { 98 | uint nIndex; 99 | Bucket *p; 100 | 101 | if (nKeyLength == 0) { 102 | return zend_hash_index_find(ht, h, pData); 103 | } 104 | 105 | nIndex = h & ht->nTableMask; 106 | 107 | p = ht->arBuckets[nIndex]; 108 | while (p != NULL) { 109 | if (p->arKey == arKey || ((p->h == h) && (p->nKeyLength == nKeyLength))) { 110 | if (!memcmp(p->arKey, arKey, nKeyLength)) { 111 | *pData = p->pData; 112 | return SUCCESS; 113 | } 114 | } 115 | p = p->pNext; 116 | } 117 | return FAILURE; 118 | } 119 | 120 | /** 121 | * Assigns the current value in a hash traversing to a zval 122 | */ 123 | void zephir_get_current_key(zval **key, const HashTable *hash_table, HashPosition *hash_position TSRMLS_DC) 124 | { 125 | Bucket *p; 126 | 127 | ZEPHIR_INIT_NVAR_PNULL(*key); 128 | 129 | p = hash_position ? (*hash_position) : hash_table->pInternalPointer; 130 | 131 | if (p) { 132 | if (p->nKeyLength) { 133 | ZVAL_STRINGL(*key, (char *) p->arKey, p->nKeyLength - 1, 0); 134 | } else { 135 | ZVAL_LONG(*key, p->h); 136 | } 137 | } 138 | 139 | } 140 | 141 | zval zephir_get_current_key_w(const HashTable *hash_table, HashPosition *hash_position) 142 | { 143 | Bucket *p; 144 | zval result; 145 | 146 | INIT_ZVAL(result); 147 | p = hash_position ? (*hash_position) : hash_table->pInternalPointer; 148 | 149 | if (p) { 150 | if (p->nKeyLength) { 151 | ZVAL_STRINGL(&result, (char *) p->arKey, p->nKeyLength - 1, 0); 152 | } else { 153 | ZVAL_LONG(&result, p->h); 154 | } 155 | } 156 | 157 | return result; 158 | } 159 | 160 | /** 161 | * Traverses the hash checking if at least one of the keys is numeric 162 | */ 163 | int zephir_has_numeric_keys(const zval *data) 164 | { 165 | HashTable *ht; 166 | 167 | if (Z_TYPE_P(data) == IS_ARRAY) { 168 | 169 | ht = Z_ARRVAL_P(data); 170 | 171 | ht->pInternalPointer = ht->pListHead; 172 | while (ht->pInternalPointer) { 173 | if (!ht->pInternalPointer->nKeyLength) { 174 | return 1; 175 | } 176 | ht->pInternalPointer = ht->pInternalPointer->pListNext; 177 | } 178 | 179 | } 180 | 181 | return 0; 182 | } 183 | 184 | /** 185 | * @brief Adds or updates item @a key in the hash table @a ht 186 | * @param ht Hash table 187 | * @param[in] key Key 188 | * @param[in] value Value 189 | * @note @a value's reference count in not updated 190 | * @note If @a key is @c NULL or is @c IS_NULL, @a value is appended to @a ht 191 | * @throw E_WARNING if @a key type is not supported 192 | */ 193 | void zephir_hash_update_or_insert(HashTable *ht, zval *key, zval *value) 194 | { 195 | if (!key || Z_TYPE_P(key) == IS_NULL) { 196 | zend_hash_next_index_insert(ht, (void**)&value, sizeof(zval*), NULL); 197 | return; 198 | } 199 | 200 | switch (Z_TYPE_P(key)) { 201 | case IS_STRING: 202 | zend_symtable_update(ht, Z_STRVAL_P(key), Z_STRLEN_P(key)+1, (void**)&value, sizeof(zval*), NULL); 203 | return; 204 | 205 | case IS_RESOURCE: 206 | case IS_DOUBLE: 207 | case IS_BOOL: 208 | case IS_LONG: 209 | zend_hash_index_update(ht, ((Z_TYPE_P(key) == IS_DOUBLE) ? (ulong)Z_DVAL_P(key) : Z_LVAL_P(key)), (void*)&value, sizeof(zval*), NULL); 210 | return; 211 | 212 | default: 213 | zend_error(E_WARNING, "Illegal offset type"); 214 | return; 215 | } 216 | } 217 | 218 | /** 219 | * @brief Returns the entry @a ht identified by @a key 220 | * @param[in] ht Hash table 221 | * @param[in] key 222 | * @param[in] type One of @c BP_VAR_XXX values 223 | * @return Pointer to the stored value or a pointer to the special variable / @c NULL if @a key was not found 224 | * @retval &EG(error_zval_ptr) when @a key was not found and @a type is one of @c BP_VAR_W, @c BP_VAR_RW 225 | * @retval &EG(uninitialized_zval_ptr) when @a key was not found and @a type is one of @c BP_VAR_R, @c BP_VAR_UNSET, @c BP_VAR_IS 226 | * @retval @c NULL when @a key was not found and @a type is not any of the above 227 | * @throw @c E_WARNING when @a key is of not supported typel in this case the function never returns @c NULL 228 | * @throw @c E_STRICT when @a key is a resource 229 | * @throw @c E_NOTICE if @a key was not found and @a type is @c BP_VAR_R or @c BP_VAR_RW 230 | * @note Reference count of the returned item is not modified 231 | * @note The implementation is suitable for @c read_property, @c get_property_ptr_ptr and @c read_dimension object handlers 232 | * @warning If @a type is @c BP_VAR_W or @c BP_VAR_RW and @a key was not found, it is added to @a ht and its value is set to @c IS_NULL 233 | */ 234 | zval** zephir_hash_get(HashTable *ht, zval *key, int type) 235 | { 236 | zval **ret = NULL; 237 | 238 | switch (Z_TYPE_P(key)) { 239 | case IS_RESOURCE: 240 | zend_error(E_STRICT, "Resource ID#%ld used as offset, casting to integer (%ld)", Z_LVAL_P(key), Z_LVAL_P(key)); 241 | /* no break */ 242 | case IS_LONG: 243 | case IS_DOUBLE: 244 | case IS_BOOL: { 245 | ulong index = (Z_TYPE_P(key) == IS_DOUBLE) ? ((long int)Z_DVAL_P(key)) : Z_LVAL_P(key); 246 | if (FAILURE == zend_hash_index_find(ht, index, (void**)&ret)) { 247 | switch (type) { 248 | case BP_VAR_R: 249 | zend_error(E_NOTICE, "Undefined offset: %ld", index); 250 | /* no break */ 251 | case BP_VAR_UNSET: 252 | case BP_VAR_IS: { 253 | TSRMLS_FETCH(); 254 | ret = &EG(uninitialized_zval_ptr); 255 | break; 256 | } 257 | 258 | case BP_VAR_RW: 259 | zend_error(E_NOTICE, "Undefined offset: %ld", index); 260 | /* no break */ 261 | case BP_VAR_W: { 262 | zval *value; 263 | ALLOC_INIT_ZVAL(value); 264 | zend_hash_index_update(ht, index, (void**)&value, sizeof(void*), (void**)&ret); 265 | break; 266 | } 267 | } 268 | } 269 | 270 | return ret; 271 | } 272 | 273 | case IS_STRING: 274 | if (FAILURE == zend_symtable_find(ht, Z_STRVAL_P(key), Z_STRLEN_P(key)+1, (void**)&ret)) { 275 | switch (type) { 276 | case BP_VAR_R: 277 | zend_error(E_NOTICE, "Undefined offset: %s", Z_STRVAL_P(key)); 278 | /* no break */ 279 | case BP_VAR_UNSET: 280 | case BP_VAR_IS: { 281 | TSRMLS_FETCH(); 282 | ret = &EG(uninitialized_zval_ptr); 283 | break; 284 | } 285 | 286 | case BP_VAR_RW: 287 | zend_error(E_NOTICE, "Undefined offset: %s", Z_STRVAL_P(key)); 288 | /* no break */ 289 | case BP_VAR_W: { 290 | zval *value; 291 | ALLOC_INIT_ZVAL(value); 292 | zend_symtable_update(ht, Z_STRVAL_P(key), Z_STRLEN_P(key)+1, (void**)&value, sizeof(void*), (void**)&ret); 293 | break; 294 | } 295 | } 296 | } 297 | 298 | return ret; 299 | 300 | default: { 301 | TSRMLS_FETCH(); 302 | zend_error(E_WARNING, "Illegal offset type"); 303 | return (type == BP_VAR_W || type == BP_VAR_RW) ? &EG(error_zval_ptr) : &EG(uninitialized_zval_ptr); 304 | } 305 | } 306 | } 307 | 308 | /** 309 | * @brief Unset @a key from @a ht 310 | * @param ht 311 | * @param key 312 | * @return 313 | */ 314 | int zephir_hash_unset(HashTable *ht, zval *key) 315 | { 316 | switch (Z_TYPE_P(key)) { 317 | case IS_LONG: 318 | case IS_DOUBLE: 319 | case IS_BOOL: 320 | case IS_RESOURCE: 321 | return (zend_hash_index_del(ht, (Z_TYPE_P(key) == IS_DOUBLE) ? ((long int)Z_DVAL_P(key)) : Z_LVAL_P(key)) == SUCCESS); 322 | 323 | case IS_STRING: 324 | return (zend_symtable_del(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1) == SUCCESS); 325 | 326 | default: 327 | zend_error(E_WARNING, "Illegal offset type"); 328 | return 0; 329 | } 330 | } 331 | 332 | 333 | -------------------------------------------------------------------------------- /ext/kernel/operators.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | +------------------------------------------------------------------------+ 4 | | Zephir Language | 5 | +------------------------------------------------------------------------+ 6 | | Copyright (c) 2011-2014 Zephir Team (http://www.zephir-lang.com) | 7 | +------------------------------------------------------------------------+ 8 | | This source file is subject to the New BSD License that is bundled | 9 | | with this package in the file docs/LICENSE.txt. | 10 | | | 11 | | If you did not receive a copy of the license and are unable to | 12 | | obtain it through the world-wide-web, please send an email | 13 | | to license@zephir-lang.com so we can send you a copy immediately. | 14 | +------------------------------------------------------------------------+ 15 | | Authors: Andres Gutierrez | 16 | | Eduar Carvajal | 17 | | Vladimir Kolesnikov | 18 | +------------------------------------------------------------------------+ 19 | */ 20 | 21 | #ifndef ZEPHIR_KERNEL_OPERATORS_H 22 | #define ZEPHIR_KERNEL_OPERATORS_H 23 | 24 | /** Strict comparing */ 25 | #define ZEPHIR_IS_LONG(op1, op2) ((Z_TYPE_P(op1) == IS_LONG && Z_LVAL_P(op1) == op2) || zephir_compare_strict_long(op1, op2 TSRMLS_CC)) 26 | #define ZEPHIR_IS_DOUBLE(op1, op2) ((Z_TYPE_P(op1) == IS_DOUBLE && Z_DVAL_P(op1) == op2) || zephir_compare_strict_double(op1, op2 TSRMLS_CC)) 27 | #define ZEPHIR_IS_STRING(op1, op2) zephir_compare_strict_string(op1, op2, strlen(op2)) 28 | 29 | #define ZEPHIR_IS_LONG_IDENTICAL(op1, op2) (Z_TYPE_P(op1) == IS_LONG && Z_LVAL_P(op1) == op2) 30 | #define ZEPHIR_IS_DOUBLE_IDENTICAL(op1, op2) (Z_TYPE_P(op1) == IS_DOUBLE && Z_DVAL_P(op1) == op2) 31 | #define ZEPHIR_IS_STRING_IDENTICAL(op1, op2) (Z_TYPE_P(op1) == IS_STRING && zephir_compare_strict_string(op1, op2, strlen(op2))) 32 | 33 | /** strict boolean comparison */ 34 | #define ZEPHIR_IS_FALSE(var) ((Z_TYPE_P(var) == IS_BOOL && !Z_BVAL_P(var)) || zephir_compare_strict_bool(var, 0 TSRMLS_CC)) 35 | #define ZEPHIR_IS_TRUE(var) ((Z_TYPE_P(var) == IS_BOOL && Z_BVAL_P(var)) || zephir_compare_strict_bool(var, 1 TSRMLS_CC)) 36 | 37 | #define ZEPHIR_IS_FALSE_IDENTICAL(var) (Z_TYPE_P(var) == IS_BOOL && !Z_BVAL_P(var)) 38 | #define ZEPHIR_IS_TRUE_IDENTICAL(var) (Z_TYPE_P(var) == IS_BOOL && Z_BVAL_P(var)) 39 | 40 | #define ZEPHIR_IS_NOT_FALSE(var) (Z_TYPE_P(var) != IS_BOOL || (Z_TYPE_P(var) == IS_BOOL && Z_BVAL_P(var))) 41 | #define ZEPHIR_IS_NOT_TRUE(var) (Z_TYPE_P(var) != IS_BOOL || (Z_TYPE_P(var) == IS_BOOL && !Z_BVAL_P(var))) 42 | #define ZEPHIR_IS_BOOL(op1, op2) ((Z_TYPE_P(op1) == IS_BOOL && Z_BVAL_P(op1) == op2) || zephir_compare_strict_bool(op1, op2 TSRMLS_CC)) 43 | 44 | /** SQL null empty **/ 45 | #define ZEPHIR_IS_EMPTY(var) (Z_TYPE_P(var) == IS_NULL || ZEPHIR_IS_FALSE(var) || (Z_TYPE_P(var) == IS_STRING && !Z_STRLEN_P(var)) || (Z_TYPE_P(var) == IS_ARRAY && zend_hash_num_elements(Z_ARRVAL_P(var)) == 0)) 46 | #define ZEPHIR_IS_NOT_EMPTY(var) (!ZEPHIR_IS_EMPTY(var)) 47 | 48 | /** Is scalar */ 49 | #define ZEPHIR_IS_SCALAR(var) (!ZEPHIR_IS_NOT_SCALAR(var)) 50 | #define ZEPHIR_IS_NOT_SCALAR(var) (Z_TYPE_P(var) == IS_NULL || Z_TYPE_P(var) == IS_ARRAY || Z_TYPE_P(var) == IS_OBJECT || Z_TYPE_P(var) == IS_RESOURCE) 51 | 52 | /** Equals/Identical */ 53 | #define ZEPHIR_IS_EQUAL(op1, op2) zephir_is_equal(op1, op2 TSRMLS_CC) 54 | #define ZEPHIR_IS_IDENTICAL(op1, op2) zephir_is_identical(op1, op2 TSRMLS_CC) 55 | 56 | /** Greater/Smaller equals */ 57 | #define ZEPHIR_LE(op1, op2) zephir_less_equal(op1, op2 TSRMLS_CC) 58 | #define ZEPHIR_LE_LONG(op1, op2) ((Z_TYPE_P(op1) == IS_LONG && Z_LVAL_P(op1) <= op2) || zephir_less_equal_long(op1, op2 TSRMLS_CC)) 59 | #define ZEPHIR_LE_DOUBLE(op1, op2) ((Z_TYPE_P(op1) == IS_DOUBLE && Z_DVAL_P(op1) <= op2) || zephir_less_equal_double(op1, op2 TSRMLS_CC)) 60 | #define ZEPHIR_GE(op1, op2) zephir_greater_equal(op1, op2 TSRMLS_CC) 61 | #define ZEPHIR_GE_LONG(op1, op2) zephir_greater_equal_long(op1, op2 TSRMLS_CC) 62 | #define ZEPHIR_LT(op1, op2) ((Z_TYPE_P(op1) == IS_LONG && Z_TYPE_P(op2) == IS_LONG) ? Z_LVAL_P(op1) < Z_LVAL_P(op2) : zephir_less(op1, op2 TSRMLS_CC)) 63 | #define ZEPHIR_LT_LONG(op1, op2) ((Z_TYPE_P(op1) == IS_LONG && Z_LVAL_P(op1) < op2) || zephir_less_long(op1, op2 TSRMLS_CC)) 64 | #define ZEPHIR_LT_DOUBLE(op1, op2) ((Z_TYPE_P(op1) == IS_DOUBLE && Z_DVAL_P(op1) < op2) || zephir_less_double(op1, op2 TSRMLS_CC)) 65 | #define ZEPHIR_GT(op1, op2) zephir_greater(op1, op2 TSRMLS_CC) 66 | #define ZEPHIR_GT_LONG(op1, op2) ((Z_TYPE_P(op1) == IS_LONG && Z_LVAL_P(op1) > op2) || zephir_greater_long(op1, op2 TSRMLS_CC)) 67 | #define ZEPHIR_GT_DOUBLE(op1, op2) ((Z_TYPE_P(op1) == IS_DOUBLE && Z_DVAL_P(op1) > op2) || zephir_greater_double(op1, op2 TSRMLS_CC)) 68 | 69 | #define ZEPHIR_STRING_OFFSET(op1, index) ((index >= 0 && index < Z_STRLEN_P(op1)) ? Z_STRVAL_P(op1)[index] : '\0') 70 | 71 | #if PHP_VERSION_ID < 50400 72 | #define zephir_increment(var) increment_function(var) 73 | #else 74 | #define zephir_increment(var) fast_increment_function(var) 75 | #endif 76 | 77 | #if PHP_VERSION_ID < 50400 78 | #define zephir_decrement(var) decrement_function(var) 79 | #else 80 | #define zephir_decrement(var) fast_decrement_function(var) 81 | #endif 82 | 83 | void zephir_make_printable_zval(zval *expr, zval *expr_copy, int *use_copy); 84 | 85 | #if PHP_VERSION_ID < 50400 86 | #define zephir_sub_function(result, left, right) sub_function(result, left, right) 87 | #else 88 | #define zephir_sub_function(result, left, right) fast_sub_function(result, left, right) 89 | #endif 90 | 91 | /** Operator functions */ 92 | int zephir_add_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); 93 | int zephir_and_function(zval *result, zval *left, zval *right); 94 | void zephir_negate(zval *z TSRMLS_DC); 95 | 96 | /** Bitwise functions */ 97 | int zephir_bitwise_and_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); 98 | int zephir_bitwise_or_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); 99 | int zephir_bitwise_xor_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); 100 | int zephir_shift_left_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); 101 | int zephir_shift_right_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); 102 | 103 | void zephir_concat_self(zval **left, zval *right TSRMLS_DC); 104 | void zephir_concat_self_str(zval **left, const char *right, int right_length TSRMLS_DC); 105 | void zephir_concat_self_long(zval **left, const long right TSRMLS_DC); 106 | void zephir_concat_self_char(zval **left, unsigned char right TSRMLS_DC); 107 | 108 | /** Strict comparing */ 109 | int zephir_compare_strict_string(zval *op1, const char *op2, int op2_length); 110 | int zephir_compare_strict_long(zval *op1, long op2 TSRMLS_DC); 111 | int zephir_compare_strict_double(zval *op1, double op2 TSRMLS_DC); 112 | int zephir_compare_strict_bool(zval *op1, zend_bool op2 TSRMLS_DC); 113 | 114 | void zephir_cast(zval *result, zval *var, zend_uint type); 115 | void zephir_convert_to_object(zval *op); 116 | long zephir_get_intval_ex(const zval *op); 117 | double zephir_get_doubleval_ex(const zval *op); 118 | zend_bool zephir_get_boolval_ex(const zval *op); 119 | 120 | int zephir_is_numeric_ex(const zval *op); 121 | 122 | int zephir_is_equal(zval *op1, zval *op2 TSRMLS_DC); 123 | int zephir_is_identical(zval *op1, zval *op2 TSRMLS_DC); 124 | 125 | int zephir_less(zval *op1, zval *op2 TSRMLS_DC); 126 | int zephir_less_long(zval *op1, long op2 TSRMLS_DC); 127 | 128 | int zephir_greater(zval *op1, zval *op2 TSRMLS_DC); 129 | int zephir_greater_long(zval *op1, long op2 TSRMLS_DC); 130 | 131 | int zephir_less_equal(zval *op1, zval *op2 TSRMLS_DC); 132 | int zephir_less_equal_long(zval *op1, long op2 TSRMLS_DC); 133 | 134 | int zephir_greater_equal(zval *op1, zval *op2 TSRMLS_DC); 135 | int zephir_greater_equal_long(zval *op1, long op2 TSRMLS_DC); 136 | 137 | #define zephir_get_numberval(z) (Z_TYPE_P(z) == IS_LONG ? Z_LVAL_P(z) : zephir_get_doubleval(z)) 138 | #define zephir_get_intval(z) (Z_TYPE_P(z) == IS_LONG ? Z_LVAL_P(z) : zephir_get_intval_ex(z)) 139 | #define zephir_get_doubleval(z) (Z_TYPE_P(z) == IS_DOUBLE ? Z_DVAL_P(z) : zephir_get_doubleval_ex(z)) 140 | #define zephir_get_boolval(z) (Z_TYPE_P(z) == IS_BOOL ? Z_BVAL_P(z) : zephir_get_boolval_ex(z)) 141 | 142 | #define ZEPHIR_ADD_ASSIGN(z, v) \ 143 | { \ 144 | zval tmp; \ 145 | ZEPHIR_SEPARATE(z); \ 146 | if (Z_TYPE_P(z) == IS_LONG && Z_TYPE_P(v) == IS_LONG) { \ 147 | Z_LVAL_P(z) += Z_LVAL_P(v); \ 148 | } else { \ 149 | if (Z_TYPE_P(z) == IS_LONG && Z_TYPE_P(v) == IS_DOUBLE) { \ 150 | Z_LVAL_P(z) += Z_DVAL_P(v); \ 151 | } else { \ 152 | zephir_add_function(&tmp, z, v TSRMLS_CC); \ 153 | if (Z_TYPE(tmp) == IS_LONG) { \ 154 | Z_LVAL_P(z) = Z_LVAL(tmp); \ 155 | } else { \ 156 | if (Z_TYPE(tmp) == IS_DOUBLE) { \ 157 | Z_DVAL_P(z) = Z_DVAL(tmp); \ 158 | } \ 159 | } \ 160 | } \ 161 | } \ 162 | } 163 | 164 | #define ZEPHIR_SUB_ASSIGN(z, v) \ 165 | { \ 166 | zval tmp; \ 167 | ZEPHIR_SEPARATE(z); \ 168 | if (Z_TYPE_P(z) == IS_LONG && Z_TYPE_P(v) == IS_LONG) { \ 169 | Z_LVAL_P(z) -= Z_LVAL_P(v); \ 170 | } else { \ 171 | if (Z_TYPE_P(z) == IS_LONG && Z_TYPE_P(v) == IS_DOUBLE) { \ 172 | Z_LVAL_P(z) -= Z_DVAL_P(v); \ 173 | } else { \ 174 | sub_function(&tmp, z, v TSRMLS_CC); \ 175 | if (Z_TYPE(tmp) == IS_LONG) { \ 176 | Z_LVAL_P(z) = Z_LVAL(tmp); \ 177 | } else { \ 178 | if (Z_TYPE(tmp) == IS_DOUBLE) { \ 179 | Z_DVAL_P(z) = Z_DVAL(tmp); \ 180 | } \ 181 | } \ 182 | } \ 183 | } \ 184 | } 185 | 186 | #define ZEPHIR_MUL_ASSIGN(z, v) \ 187 | { \ 188 | zval tmp; \ 189 | ZEPHIR_SEPARATE(z); \ 190 | if (Z_TYPE_P(z) == IS_LONG && Z_TYPE_P(v) == IS_LONG) { \ 191 | Z_LVAL_P(z) *= Z_LVAL_P(v); \ 192 | } else { \ 193 | if (Z_TYPE_P(z) == IS_LONG && Z_TYPE_P(v) == IS_DOUBLE) { \ 194 | Z_LVAL_P(z) *= Z_DVAL_P(v); \ 195 | } else { \ 196 | sub_function(&tmp, z, v TSRMLS_CC); \ 197 | if (Z_TYPE(tmp) == IS_LONG) { \ 198 | Z_LVAL_P(z) = Z_LVAL(tmp); \ 199 | } else { \ 200 | if (Z_TYPE(tmp) == IS_DOUBLE) { \ 201 | Z_DVAL_P(z) = Z_DVAL(tmp); \ 202 | } \ 203 | } \ 204 | } \ 205 | } \ 206 | } 207 | 208 | #define zephir_get_strval(left, right) \ 209 | { \ 210 | int use_copy_right; \ 211 | zval right_tmp; \ 212 | if (Z_TYPE_P(right) == IS_STRING) { \ 213 | ZEPHIR_CPY_WRT(left, right); \ 214 | } else { \ 215 | INIT_ZVAL(right_tmp); \ 216 | zephir_make_printable_zval(right, &right_tmp, &use_copy_right); \ 217 | if (use_copy_right) { \ 218 | ZEPHIR_INIT_NVAR(left); \ 219 | ZVAL_STRINGL(left, Z_STRVAL_P(&right_tmp), Z_STRLEN_P(&right_tmp), 0); \ 220 | } \ 221 | } \ 222 | } 223 | 224 | #define zephir_get_arrval(returnValue, passValue) \ 225 | { \ 226 | if (Z_TYPE_P(passValue) == IS_ARRAY) { \ 227 | ZEPHIR_CPY_WRT(returnValue, passValue); \ 228 | } else { \ 229 | ZEPHIR_INIT_NVAR(returnValue); \ 230 | array_init_size(returnValue, 0); \ 231 | } \ 232 | } 233 | 234 | #define zephir_is_numeric(value) (Z_TYPE_P(value) == IS_LONG || Z_TYPE_P(value) == IS_DOUBLE || zephir_is_numeric_ex(value)) 235 | 236 | #define zephir_is_true(value) \ 237 | (Z_TYPE_P(value) == IS_NULL ? 0 : \ 238 | (Z_TYPE_P(value) == IS_BOOL ? Z_BVAL_P(value) : \ 239 | (Z_TYPE_P(value) == IS_LONG ? Z_LVAL_P(value) : \ 240 | zend_is_true(value) \ 241 | ) \ 242 | ) \ 243 | ) 244 | 245 | #endif 246 | --------------------------------------------------------------------------------