diff --git a/Library/Bootstrap.php b/Library/Bootstrap.php index 50a18421356..1df36494f96 100644 --- a/Library/Bootstrap.php +++ b/Library/Bootstrap.php @@ -132,10 +132,13 @@ public static function boot() */ foreach (new DirectoryIterator(ZEPHIRPATH . 'Library/Commands') as $item) { if (!$item->isDir()) { - require $item->getRealPath(); - $className = str_replace('.php', '', $item->getBaseName()) . 'Command'; - $command = new $className(); - self::$_commands[$command->getCommands()] = $command; + require_once $item->getRealPath(); + $className = 'Command' . str_replace('.php', '', $item->getBaseName()); + $class = new ReflectionClass($className); + if (!$class->isAbstract() && !$class->isInterface()) { + $command = new $className(); + self::$_commands[$command->getCommand()] = $command; + } } } diff --git a/Library/Commands/Abstract.php b/Library/Commands/Abstract.php new file mode 100644 index 00000000000..ebddd9c628a --- /dev/null +++ b/Library/Commands/Abstract.php @@ -0,0 +1,60 @@ +getCommand(); + $compiler->$command($this); + } +} diff --git a/Library/Commands/Clean.php b/Library/Commands/Clean.php new file mode 100644 index 00000000000..6480ea32ea2 --- /dev/null +++ b/Library/Commands/Clean.php @@ -0,0 +1,55 @@ +compile($config, $logger); - $compiler->install($config, $logger); + return 'Compile a Zephir extension'; } - } diff --git a/Library/Commands/Generate.php b/Library/Commands/Generate.php index 5d697fe6190..3086c8edf77 100644 --- a/Library/Commands/Generate.php +++ b/Library/Commands/Generate.php @@ -18,19 +18,19 @@ */ /** - * GenerateCommand + * CommandGenerate * * Generate the code without compiling it */ -class GenerateCommand +class CommandGenerate extends CommandAbstract { /** - * Commands provided by this command + * Command provided by this command * * @return array|string */ - public function getCommands() + public function getCommand() { return 'generate'; } @@ -50,19 +50,6 @@ public function getUsage() */ public function getDescription() { - return 'Compiles the extension without install it'; + return 'Generates C code from the Zephir code'; } - - /** - * Executes the command - * - * Config $config - * Logger $logger - */ - public function execute(Config $config, Logger $logger) - { - $compiler = new Compiler(); - $compiler->compile($config, $logger); - } - } diff --git a/Library/Commands/Help.php b/Library/Commands/Help.php index bd81bd19fbf..b1eddc60a1d 100644 --- a/Library/Commands/Help.php +++ b/Library/Commands/Help.php @@ -18,11 +18,11 @@ */ /** - * HelpCommand + * CommandHelp * * Shows compiler help */ -class HelpCommand +class CommandHelp extends CommandAbstract { const LOGO =' _____ __ _ @@ -34,11 +34,11 @@ class HelpCommand '; /** - * Commands provided by this command + * Command provided by this command * - * @return array|string + * @return string */ - public function getCommands() + public function getCommand() { return 'help'; } @@ -58,7 +58,7 @@ public function getUsage() */ public function getDescription() { - return 'Displays help'; + return 'Displays this help'; } /** @@ -69,9 +69,8 @@ public function getDescription() */ public function execute(Config $config, Logger $logger) { - echo self::LOGO, PHP_EOL; - echo "zephir version " , VersionCommand::VERSION, PHP_EOL, PHP_EOL; + echo "zephir version " , CommandVersion::VERSION, PHP_EOL, PHP_EOL; echo "Usage: ", PHP_EOL; echo "\tcommand [options]", PHP_EOL; echo PHP_EOL; @@ -84,7 +83,5 @@ public function execute(Config $config, Logger $logger) echo sprintf("\t%-20s%s\n", "-fno-([a-z0-9\-]+)", "Setting options to Compiler"); echo sprintf("\t%-20s%s\n", "-W([a-z0-9\-]+)", "Setting warning options to Compiler"); echo PHP_EOL; - } - } diff --git a/Library/Commands/Initialize.php b/Library/Commands/Initialize.php index 8ddfab7cd7c..740d19cd4a5 100644 --- a/Library/Commands/Initialize.php +++ b/Library/Commands/Initialize.php @@ -18,19 +18,20 @@ */ /** - * InitializeCommand + * CommandInitialize * - * Shows Zephir version + * Initialize a zephir extension */ -class InitializeCommand +class CommandInitialize extends CommandAbstract { - + private $_namespace; + /** - * Commands provided by this command + * Command provided by this command * - * @return array|string + * @return string */ - public function getCommands() + public function getCommand() { return 'init'; } @@ -53,16 +54,16 @@ public function getDescription() return 'Initializes a Zephir extension'; } - /** - * Executes the command - * - * Config $config - * Logger $logger - */ - public function execute(Config $config, Logger $logger) + public function getNamespace() { - $compiler = new Compiler(); - $compiler->init($config, $logger); + return $this->_namespace; } + public function execute(Config $config, Logger $logger) + { + if (isset($_SERVER['argv'][2])) { + $this->_namespace = strtolower(preg_replace('/[^0-9a-zA-Z]/', '', $_SERVER['argv'][2])); + } + parent::execute($config, $logger); + } } diff --git a/Library/Commands/Install.php b/Library/Commands/Install.php index 851d36ee1d6..64f1bdadd5b 100644 --- a/Library/Commands/Install.php +++ b/Library/Commands/Install.php @@ -18,19 +18,19 @@ */ /** - * InstallCommand + * CommandInstall * * Produce the extension installation */ -class InstallCommand +class CommandInstall extends CommandAbstract { /** - * Commands provided by this command + * Command provided by this command * - * @return array|string + * @return string */ - public function getCommands() + public function getCommand() { return 'install'; } @@ -50,19 +50,6 @@ public function getUsage() */ public function getDescription() { - return 'Installs the extension'; - } - - /** - * Executes the command - * - * Config $config - * Logger $logger - */ - public function execute(Config $config, Logger $logger) - { - $compiler = new Compiler(); - $compiler->install($config, $logger); + return 'Installs the extension (requires root password)'; } - } diff --git a/Library/Commands/Interface.php b/Library/Commands/Interface.php new file mode 100644 index 00000000000..e61809a4081 --- /dev/null +++ b/Library/Commands/Interface.php @@ -0,0 +1,54 @@ +_config = $config; + $this->_logger = $logger; + /** + * The string manager manages + */ + $this->_stringManager = new StringsManager(); + } /** * Pre-compiles classes creating a CompilerFile definition * @@ -53,7 +68,7 @@ protected function _preCompile($filePath) $className = join('\\', array_map(function($i) { return ucfirst($i); }, explode('\\', $className))); - $this->_files[$className] = new CompilerFile($className, $filePath); + $this->_files[$className] = new CompilerFile($className, $filePath, $this->_config, $this->_logger); $this->_files[$className]->preCompile(); $this->_definitions[$className] = $this->_files[$className]->getClassDefinition(); } @@ -175,27 +190,35 @@ public function getInternalClassDefinition($className) * @param string $path * @param string $destination */ - protected function _copyBaseKernel($path, $destination) + protected function _recursiveProcess($src, $dest, $pattern=null, $callback = "copy") { - /** - * Pre compile all files - */ - $iterator = new DirectoryIterator($path); + $success = true; + $iterator = new DirectoryIterator($src); foreach ($iterator as $item) { + $pathName = $item->getPathname(); + if (!is_readable($pathName)) { + continue; + } + $fileName = $item->getFileName(); if ($item->isDir()) { - if ($item->getFileName() != '.' && $item->getFileName() != '..') { - $this->_copyBaseKernel($item->getPathname(), $destination); - } - } else { - if (preg_match('/\.[hc]$/', $item->getPathname())) { - if (strpos($item->getPathName(), 'alternative') !== false) { - copy($item->getPathname(), $destination . '/ext/kernel/alternative/' . $item->getBaseName()); - } else { - copy($item->getPathname(), $destination . '/ext/kernel/' . $item->getBaseName()); - } - } + if ($fileName != '.' && $fileName != '..') { + if (!is_dir($dest . '/' . $fileName)) { + mkdir($dest . '/' . $fileName); + } + $this->_recursiveProcess($pathName, $dest.'/'.$fileName, $pattern, $callback); + } + } else if (!$pattern || ($pattern && preg_match($pattern, $fileName) === 1)) { + if (is_string($callback)) + { + $success = $success && $callback($pathName, $dest.'/'.$fileName); + } + else + { + $success = $success && call_user_func($callback, $pathName, $dest.'/'.$fileName); + } } } + return $success; } /** @@ -276,101 +299,67 @@ public function getExtensionGlobal($name) return $this->_globals[$name]; } + protected function _checkDirectory() + { + $namespace = $this->_config->get('namespace'); + if (!$namespace) { + throw new Exception("Extension namespace cannot be loaded"); + } + + if (!is_dir('.temp')) { + mkdir('.temp'); + } + + return $namespace; + } + /** * Initializes a Zephir extension - * - * @param Config $config - * @param Logger $logger */ - public function init(Config $config, Logger $logger) + public function init(CommandInitialize $command) { - /** * If init namespace is specified */ - $namespace = null; - if (isset($_SERVER['argv'][2])) { - $namespace = strtolower(preg_replace('/[^0-9a-zA-Z]/', '', $_SERVER['argv'][2])); - } + $namespace = $command->getNamespace(); if (!$namespace) { throw new Exception("Cannot obtain a valid initial namespace for the project"); } - /** - * Using json_encode with pretty-print - */ - $configArray = array( - 'namespace' => $namespace, - 'name' => $namespace, - 'description' => '', - 'author' => '' - ); + $this->_config->set('namespace', $namespace); + $this->_config->set('name', $namespace); if (!is_dir($namespace)) { mkdir($namespace); } - if (!is_dir($namespace . '/'. $namespace)) { - mkdir($namespace . '/'. $namespace); - } - - if (!is_dir($namespace . '/.temp')) { - mkdir($namespace . '/.temp'); - } - - /** - * Above PHP 5.4 - */ - if (defined('JSON_PRETTY_PRINT')) { - $configArray = json_encode($configArray, JSON_PRETTY_PRINT); - } else { - $configArray = json_encode($configArray); + chdir($namespace); + if (!is_dir($namespace)) { + mkdir($namespace); } - file_put_contents($namespace . '/config.json', $configArray); /** * Create 'kernel' */ - if (!is_dir($namespace . '/ext')) { - - mkdir($namespace . '/ext'); - mkdir($namespace . '/ext/kernel'); - mkdir($namespace . '/ext/kernel/alternative'); - - $this->_copyBaseKernel(__DIR__ . '/../ext/kernel/', $namespace); - } - - } - - protected function _checkDirectory() - { - if (!file_exists('config.json')) { - throw new Exception("There is no Zephir extension initialized in this directory"); - } - - if (!is_dir('.temp')) { - mkdir('.temp'); + if (!is_dir('ext/kernel')) { + mkdir('ext/kernel', 0755, true); } + // Copy the latest kernel files + $this->_recursiveProcess(realpath(__DIR__ . '/../ext/kernel'), 'ext/kernel'); } /** - * - * @param Config $config - * @param Logger $logger + * + * @param CommandGenerate $command + * @throws Exception */ - public function compile(Config $config, Logger $logger) + public function generate(CommandInterface $command) { - - $this->_checkDirectory(); - /** * Get global namespace */ - $namespace = $config->get('namespace'); - if (!$namespace) { - throw new Exception("Extension namespace cannot be loaded"); - } + $namespace = $this->_checkDirectory(); /** * Round 1. pre-compile all files in memory @@ -384,13 +373,13 @@ public function compile(Config $config, Logger $logger) * Round 2. Check 'extends' and 'implements' dependencies */ foreach ($this->_files as $compileFile) { - $compileFile->checkDependencies($this, $config, $logger); + $compileFile->checkDependencies($this); } /** * Convert C-constants into PHP constants */ - $constantsSources = $config->get('constants-sources'); + $constantsSources = $this->_config->get('constants-sources'); if (is_array($constantsSources)) { $this->_loadConstantsSources($constantsSources); } @@ -398,58 +387,150 @@ public function compile(Config $config, Logger $logger) /** * Set extension globals */ - $globals = $config->get('globals'); + $globals = $this->_config->get('globals'); if (is_array($globals)) { $this->_setExtensionGlobals($globals); } - /** - * The string manager manages - */ - $stringManager = new StringsManager(); - /** * Round 3. compile all files to C sources */ $files = array(); foreach ($this->_files as $compileFile) { - $compileFile->compile($this, $config, $logger, $stringManager); + $compileFile->compile($this, $this->_stringManager); $files[] = $compileFile->getCompiledFile(); } $this->_compiledFiles = $files; + } + + /** + * + * @param CommandCompile $command + */ + public function compile(CommandInterface $command) + { + + /** + * Get global namespace + */ + $namespace = $this->_checkDirectory(); + + $this->generate($command); /** * Round 4. Create config.m4 and config.w32 files / Create project.c and project.h files */ $this->createConfigFiles($namespace, $config, $logger); $this->createProjectFiles($namespace, $config, $logger); + $needConfigure = $this->createConfigFiles($namespace); /** * Round 5. */ - $stringManager->genConcatCode(); + $this->_stringManager->genConcatCode(); + $verbose = ($this->_config->get('verbose') ? true : false); + if (!$this->_config->get('phpized')) { + echo "Preparing for PHP compilation...\n"; + exec('cd ext && phpize', $output, $exit); + $this->_config->set('phpized', true); + } + if ($needConfigure) { + echo "Preparing configuration file...\n"; + exec('export CC="gcc" && export CFLAGS="-O2" && cd ext && ./configure --enable-' . $namespace); + } + echo "Compiling...\n"; + if ($verbose) { + passthru('cd ext && make', $exit); + } else { + exec('cd ext && make' . $verbose, $output, $exit); + } } /** + * * Compiles and installs the extension - * - * @param Config $config - * @param Logger $logger + * @param CommandInstall $command + * @throws Exception */ - public function install(Config $config, Logger $logger) + public function install(CommandInstall $command) { + /** + * Get global namespace + */ + $namespace = $this->_checkDirectory(); - $namespace = $config->get('namespace'); - if (!$namespace) { - throw new Exception("Extension namespace cannot be loaded"); + $this->compile($command); + + echo "Installing...\n"; + exec('(export CC="gcc" && export CFLAGS="-O2" && cd ext && sudo make install) > /dev/null 2>&1', $output, $exit); + echo "Don't forget to restart your web server\n"; + } + + /** + * Run tests + * @param CommandInterface $command + */ + public function test(CommandInterface $command) + { + /** + * Get global namespace + */ + $namespace = $this->_checkDirectory(); + + echo "Running tests...\n"; + system('export CC="gcc" && export CFLAGS="-O0 -g" && export NO_INTERACTION=1 && cd ext && make test', $exit); + } + + /** + * Clean the extension directory + * @param CommandClean $command + */ + public function clean(CommandClean $command) + { + system('cd ext && make clean 1> /dev/null'); + } + + /** + * Checks if the content of the file on the disk is the same as + * the content. + * Returns true if the file has been written + * @param string $content + * @param string $path + */ + protected function _checkAndWriteIfNeeded($content, $path) + { + if (file_exists($path)) + { + $content_md5 = md5($content); + $existing_md5 = md5_file($path); + if ($content_md5 != $existing_md5) + { + file_put_contents($path, $content); + return true; + } } + return false; + } - if (!file_exists('ext/Makefile')) { - system('export CC="gcc" && export CFLAGS="-O2" && cd ext && phpize --silent && ./configure --silent --enable-' . $namespace . ' && sudo make --silent install 1> /dev/null'); - } else { - system('cd ext && sudo make --silent install 1> /dev/null'); + protected function _checkKernelFile($src, $dst) + { + if (strstr($src, 'ext/kernel/concat.') !== false) + { + return true; + } + $srcmd5 = md5_file($src); + $dstmd5 = md5_file($dst); + return ($srcmd5 == $dstmd5); + } + + protected function checkKernelFiles() + { + if (!$this->_recursiveProcess(realpath(__DIR__ . '/../ext/kernel'), 'ext/kernel', NULL, array($this, '_checkKernelFile'))) + { + echo "Copying new kernel files...\n"; + $this->_recursiveProcess(realpath(__DIR__ . '/../ext/kernel'), 'ext/kernel'); } } @@ -457,10 +538,12 @@ public function install(Config $config, Logger $logger) * Create config.m4 and config.w32 by compiled files to test extension * * @param string $project + * @return bool true if need to run configure */ public function createConfigFiles($project) { + $need_configure = false; $content = file_get_contents(__DIR__ . '/../templates/config.m4'); if (empty($content)) { throw new Exception("Template config.m4 doesn't exists"); @@ -476,8 +559,8 @@ public function createConfigFiles($project) foreach ($toReplace as $mark => $replace) { $content = str_replace($mark, $replace, $content); } - - file_put_contents('ext/config.m4', $content); + + $need_configure = $this->_checkAndWriteIfNeeded($content, 'ext/config.m4'); /** * php_ext.h @@ -495,7 +578,7 @@ public function createConfigFiles($project) $content = str_replace($mark, $replace, $content); } - file_put_contents('ext/php_ext.h', $content); + $this->_checkAndWriteIfNeeded($content, 'ext/php_ext.h'); /** * ext.h @@ -513,7 +596,7 @@ public function createConfigFiles($project) $content = str_replace($mark, $replace, $content); } - file_put_contents('ext/ext.h', $content); + $this->_checkAndWriteIfNeeded($content, 'ext/ext.h'); /** * ext_config.h @@ -531,7 +614,43 @@ public function createConfigFiles($project) $content = str_replace($mark, $replace, $content); } - file_put_contents('ext/ext_config.h', $content); + $this->_checkAndWriteIfNeeded($content, 'ext/ext_config.h'); + + /** + * ext_clean + */ + $content = file_get_contents(__DIR__ . '/../ext/clean'); + if (empty($content)) { + throw new Exception("clean file doesn't exists"); + } + + if ($this->_checkAndWriteIfNeeded($content, 'ext/clean')) + { + chmod('ext/clean', 0755); + } + + /** + * ext_install + */ + $content = file_get_contents(__DIR__ . '/../ext/install'); + if (empty($content)) { + throw new Exception("install file doesn't exists"); + } + + $toReplace = array( + '%PROJECT_LOWER%' => strtolower($project) + ); + + foreach ($toReplace as $mark => $replace) { + $content = str_replace($mark, $replace, $content); + } + + if ($this->_checkAndWriteIfNeeded($content, 'ext/install')) + { + chmod('ext/install', 0755); + } + + return $need_configure; } /** @@ -542,6 +661,7 @@ public function createConfigFiles($project) public function createProjectFiles($project, $config, $logger) { + $this->checkKernelFiles(); /** * project.c */ @@ -650,7 +770,7 @@ public function createProjectFiles($project, $config, $logger) /** * Round 3. Generate and place the entry point of the project */ - file_put_contents('ext/' . $project . '.c', $content); + $this->_checkAndWriteIfNeeded($content, 'ext/' . $project . '.c'); unset($content); /** @@ -678,7 +798,8 @@ public function createProjectFiles($project, $config, $logger) $content = str_replace($mark, $replace, $content); } - file_put_contents('ext/' . $project . '.h', $content); + $this->_checkAndWriteIfNeeded($content, 'ext/' . $project . '.h'); + unset($content); /** * Round 5. Create php_project.h @@ -725,8 +846,8 @@ public function createProjectFiles($project, $config, $logger) $content = str_replace($mark, $replace, $content); } - file_put_contents('ext/php_' . $project . '.h', $content); - + $this->_checkAndWriteIfNeeded($content, 'ext/php_' . $project . '.h'); + unset($content); } /** diff --git a/Library/CompilerFile.php b/Library/CompilerFile.php index a5bab9ede5c..44ec9483df0 100644 --- a/Library/CompilerFile.php +++ b/Library/CompilerFile.php @@ -43,19 +43,25 @@ class CompilerFile protected $_headerCBlocks; + protected $_config = null; + + protected $_logger = null; + /** * CompilerFile constructor * * @param string $className * @param string $filePath */ - public function __construct($className, $filePath) + public function __construct($className, $filePath, Config $config, Logger $logger) { $this->_className = $className; $this->_filePath = $filePath; $this->_compiledFilePath = preg_replace('/\.zep$/', '', $className); $this->_filesCompiled = array(); $this->_headerCBlocks = array(); + $this->_config = $config; + $this->_logger = $logger; } /** @@ -431,10 +437,8 @@ public function getCompiledFile() * Check dependencies * * @param \Compiler $compiler - * @param \Config $config - * @param \Logger $logger */ - public function checkDependencies(Compiler $compiler, Config $config, Logger $logger) + public function checkDependencies(Compiler $compiler) { $classDefinition = $this->_classDefinition; @@ -472,11 +476,9 @@ public function checkDependencies(Compiler $compiler, Config $config, Logger $lo * Compiles the file * * @param \Compiler $compiler - * @param \Config $config - * @param \Logger $logger * @param \StringsManager $stringsManager */ - public function compile(Compiler $compiler, Config $config, Logger $logger, StringsManager $stringsManager) + public function compile(Compiler $compiler, StringsManager $stringsManager) { /** @@ -492,12 +494,12 @@ public function compile(Compiler $compiler, Config $config, Logger $logger, Stri /** * Set global config in the compilation context */ - $compilationContext->config = $config; + $compilationContext->config = $this->_config; /** * Set global logger in the compilation context */ - $compilationContext->logger = $logger; + $compilationContext->logger = $this->_logger; /** * Set global strings manager diff --git a/Library/Config.php b/Library/Config.php index 7863aac01cc..736b33a1b24 100644 --- a/Library/Config.php +++ b/Library/Config.php @@ -29,7 +29,11 @@ class Config 'static-type-inference-second-pass' => true, 'local-context-pass' => true, 'constant-folding' => true, - 'static-constant-class-folding' => true + 'static-constant-class-folding' => true, + 'namespace' => '', + 'name' => '', + 'description' => '', + 'author' => '' ); public function __construct() @@ -37,10 +41,11 @@ public function __construct() if (file_exists('config.json')) { $config = json_decode(file_get_contents('config.json'), true); if (!is_array($config)) { - throw new Exception("config.json is not valid"); + throw new Exception("config.json is not valid or there is no Zephir extension initialized in this directory"); } $this->_config = array_merge($this->_config, $config); } + register_shutdown_function(array($this, '_saveOnExit')); } /** @@ -65,4 +70,16 @@ public function set($key, $value) $this->_config[$key] = $value; } + public function _saveOnExit() + { + /** + * Above PHP 5.4 + */ + if (defined('JSON_PRETTY_PRINT')) { + $config = json_encode($this->_config, JSON_PRETTY_PRINT); + } else { + $config = json_encode($this->_config); + } + file_put_contents('config.json', $config); + } } diff --git a/Library/Operators/Comparison/IdenticalOperator.php b/Library/Operators/Comparison/IdenticalOperator.php index a9a12e9e9a4..2d02ec923ef 100644 --- a/Library/Operators/Comparison/IdenticalOperator.php +++ b/Library/Operators/Comparison/IdenticalOperator.php @@ -27,6 +27,8 @@ class IdenticalOperator extends ComparisonBaseOperator protected $_zvalOperator = 'ZEPHIR_IS_IDENTICAL'; + protected $_zvalLongOperator = 'ZEPHIR_IS_LONG'; + protected $_zvalStringOperator = 'ZEPHIR_IS_STRING'; protected $_zvalBoolTrueOperator = 'ZEPHIR_IS_TRUE'; diff --git a/Library/Statements/DeclareStatement.php b/Library/Statements/DeclareStatement.php index b9a2aefd511..8278fa5b718 100644 --- a/Library/Statements/DeclareStatement.php +++ b/Library/Statements/DeclareStatement.php @@ -83,7 +83,7 @@ public function compile(CompilationContext $compilationContext) */ $symbolVariable->setOriginal($variable); - if (isset($variable['expr'])) { + if (isset($variable['expr']['value'])) { $defaultValue = $variable['expr']['value']; } else { $defaultValue = null; diff --git a/Library/StringsManager.php b/Library/StringsManager.php index 11f604bb58f..f1d852d3c40 100644 --- a/Library/StringsManager.php +++ b/Library/StringsManager.php @@ -34,6 +34,28 @@ class StringsManager 'sv' => true ); + /** + * Checks if the content of the file on the disk is the same as + * the content. + * Returns true if the file has been written + * @param string $content + * @param string $path + */ + protected function _checkAndWriteIfNeeded($content, $path) + { + if (file_exists($path)) + { + $content_md5 = md5($content); + $existing_md5 = md5_file($path); + if ($content_md5 != $existing_md5) + { + file_put_contents($path, $content); + return true; + } + } + return false; + } + /** * @param string $path */ @@ -169,8 +191,8 @@ public function genConcatCode() $code .= "}" . PHP_EOL . PHP_EOL; } - file_put_contents('ext/kernel/concat.h', join(PHP_EOL, $macros) . PHP_EOL . PHP_EOL . $codeh); - file_put_contents('ext/kernel/concat.c', $code); + $this->_checkAndWriteIfNeeded(join(PHP_EOL, $macros) . PHP_EOL . PHP_EOL . $codeh, 'ext/kernel/concat.h'); + $this->_checkAndWriteIfNeeded($code, 'ext/kernel/concat.c'); } public function getConcatKeys() diff --git a/ext/kernel/fcall.h b/ext/kernel/fcall.h index 1ff296988f8..8b10db18675 100755 --- a/ext/kernel/fcall.h +++ b/ext/kernel/fcall.h @@ -411,6 +411,48 @@ ZEPHIR_CALL_METHOD(return_value, return_value_ptr, object, method_name, key, 5, p1, p2, p3, p4, p5); \ } while (0) +#define zephir_call_method_p6_key_ex(return_value, return_value_ptr, object, method_name, key, p1, p2, p3, p4, p5, p6) \ + do { \ + if (0) { \ + if (Z_TYPE_P(p1)) {} \ + if (Z_TYPE_P(p2)) {} \ + if (Z_TYPE_P(p3)) {} \ + if (Z_TYPE_P(p4)) {} \ + if (Z_TYPE_P(p5)) {} \ + if (Z_TYPE_P(p6)) {} \ + } \ + ZEPHIR_CALL_METHOD(return_value, return_value_ptr, object, method_name, key, 5, p1, p2, p3, p4, p5, p6); \ + } while (0) + +#define zephir_call_method_p7_key_ex(return_value, return_value_ptr, object, method_name, key, p1, p2, p3, p4, p5, p6, p7) \ + do { \ + if (0) { \ + if (Z_TYPE_P(p1)) {} \ + if (Z_TYPE_P(p2)) {} \ + if (Z_TYPE_P(p3)) {} \ + if (Z_TYPE_P(p4)) {} \ + if (Z_TYPE_P(p5)) {} \ + if (Z_TYPE_P(p6)) {} \ + if (Z_TYPE_P(p7)) {} \ + } \ + ZEPHIR_CALL_METHOD(return_value, return_value_ptr, object, method_name, key, 5, p1, p2, p3, p4, p5, p6, p7); \ + } while (0) + +#define zephir_call_method_p8_key_ex(return_value, return_value_ptr, object, method_name, key, p1, p2, p3, p4, p5, p6, p7, p8) \ + do { \ + if (0) { \ + if (Z_TYPE_P(p1)) {} \ + if (Z_TYPE_P(p2)) {} \ + if (Z_TYPE_P(p3)) {} \ + if (Z_TYPE_P(p4)) {} \ + if (Z_TYPE_P(p5)) {} \ + if (Z_TYPE_P(p6)) {} \ + if (Z_TYPE_P(p7)) {} \ + if (Z_TYPE_P(p8)) {} \ + } \ + ZEPHIR_CALL_METHOD(return_value, return_value_ptr, object, method_name, key, 5, p1, p2, p3, p4, p5, p6, p7, p8); \ + } while (0) + /** Macros to call methods in the PHP userland (keeping the call cache) */ #define zephir_call_method_p0_cache_key_ex(return_value, return_value_ptr, object, method_name, key, cache) \ do { \ @@ -467,110 +509,176 @@ ZEPHIR_CALL_METHOD_CACHE(return_value, return_value_ptr, object, method_name, key, cache, 5, p1, p2, p3, p4, p5); \ } while (0) -#define zephir_call_method_p0_ex(return_value, return_value_ptr, object, method_name) zephir_call_method_p0_key_ex(return_value, return_value_ptr, object, method_name, 0) -#define zephir_call_method_p1_ex(return_value, return_value_ptr, object, method_name, p1) zephir_call_method_p1_key_ex(return_value, return_value_ptr, object, method_name, 0, p1) -#define zephir_call_method_p2_ex(return_value, return_value_ptr, object, method_name, p1, p2) zephir_call_method_p2_key_ex(return_value, return_value_ptr, object, method_name, 0, p1, p2) -#define zephir_call_method_p3_ex(return_value, return_value_ptr, object, method_name, p1, p2, p3) zephir_call_method_p3_key_ex(return_value, return_value_ptr, object, method_name, 0, p1, p2, p3) -#define zephir_call_method_p4_ex(return_value, return_value_ptr, object, method_name, p1, p2, p3, p4) zephir_call_method_p4_key_ex(return_value, return_value_ptr, object, method_name, 0, p1, p2, p3, p4) -#define zephir_call_method_p5_ex(return_value, return_value_ptr, object, method_name, p1, p2, p3, p4, p5) zephir_call_method_p5_key_ex(return_value, return_value_ptr, object, method_name, 0, p1, p2, p3, p4, p5) - -#define zephir_call_method_p0_cache_ex(return_value, return_value_ptr, object, method_name, cache) zephir_call_method_p0_cache_key_ex(return_value, return_value_ptr, object, method_name, 0, cache) -#define zephir_call_method_p1_cache_ex(return_value, return_value_ptr, object, method_name, cache, p1) zephir_call_method_p1_cache_key_ex(return_value, return_value_ptr, object, method_name, 0, cache, p1) -#define zephir_call_method_p2_cache_ex(return_value, return_value_ptr, object, method_name, cache, p1, p2) zephir_call_method_p2_cache_key_ex(return_value, return_value_ptr, object, method_name, 0, cache, p1, p2) -#define zephir_call_method_p3_cache_ex(return_value, return_value_ptr, object, method_name, cache, p1, p2, p3) zephir_call_method_p3_cache_key_ex(return_value, return_value_ptr, object, method_name, 0, cache, p1, p2, p3) -#define zephir_call_method_p4_cache_ex(return_value, return_value_ptr, object, method_name, cache, p1, p2, p3, p4) zephir_call_method_p4_cache_key_ex(return_value, return_value_ptr, object, method_name, 0, cache, p1, p2, p3, p4) -#define zephir_call_method_p5_cache_ex(return_value, return_value_ptr, object, method_name, cache, p1, p2, p3, p4, p5) zephir_call_method_p5_cache_key_ex(return_value, return_value_ptr, object, method_name, 0, cache, p1, p2, p3, p4, p5) - -#define zephir_call_method(return_value, object, method_name) zephir_call_method_p0_ex(return_value, NULL, object, method_name) -#define zephir_call_method_p1(return_value, object, method_name, p1) zephir_call_method_p1_ex(return_value, NULL, object, method_name, p1) -#define zephir_call_method_p2(return_value, object, method_name, p1, p2) zephir_call_method_p2_ex(return_value, NULL, object, method_name, p1, p2) -#define zephir_call_method_p3(return_value, object, method_name, p1, p2, p3) zephir_call_method_p3_ex(return_value, NULL, object, method_name, p1, p2, p3) -#define zephir_call_method_p4(return_value, object, method_name, p1, p2, p3, p4) zephir_call_method_p4_ex(return_value, NULL, object, method_name, p1, p2, p3, p4) -#define zephir_call_method_p5(return_value, object, method_name, p1, p2, p3, p4, p5) zephir_call_method_p5_ex(return_value, NULL, object, method_name, p1, p2, p3, p4, p5) - -#define zephir_call_method_noret(object, method_name) zephir_call_method_p0_ex(NULL, NULL, object, method_name) -#define zephir_call_method_p1_noret(object, method_name, p1) zephir_call_method_p1_ex(NULL, NULL, object, method_name, p1) -#define zephir_call_method_p2_noret(object, method_name, p1, p2) zephir_call_method_p2_ex(NULL, NULL, object, method_name, p1, p2) -#define zephir_call_method_p3_noret(object, method_name, p1, p2, p3) zephir_call_method_p3_ex(NULL, NULL, object, method_name, p1, p2, p3) -#define zephir_call_method_p4_noret(object, method_name, p1, p2, p3, p4) zephir_call_method_p4_ex(NULL, NULL, object, method_name, p1, p2, p3, p4) -#define zephir_call_method_p5_noret(object, method_name, p1, p2, p3, p4, p5) zephir_call_method_p5_ex(NULL, NULL, object, method_name, p1, p2, p3, p4, p5) - -#define zephir_call_method_cache(return_value, object, method_name, cache) zephir_call_method_p0_cache_ex(return_value, NULL, object, method_name, cache) -#define zephir_call_method_p1_cache(return_value, object, method_name, cache, p1) zephir_call_method_p1_cache_ex(return_value, NULL, object, method_name, cache, p1) -#define zephir_call_method_p2_cache(return_value, object, method_name, cache, p1, p2) zephir_call_method_p2_cache_ex(return_value, NULL, object, method_name, cache, p1, p2) -#define zephir_call_method_p3_cache(return_value, object, method_name, cache, p1, p2, p3) zephir_call_method_p3_cache_ex(return_value, NULL, object, method_name, cache, p1, p2, p3) -#define zephir_call_method_p4_cache(return_value, object, method_name, cache, p1, p2, p3, p4) zephir_call_method_p4_cache_ex(return_value, NULL, object, method_name, cache, p1, p2, p3, p4) -#define zephir_call_method_p5_cache(return_value, object, method_name, cache, p1, p2, p3, p4, p5) zephir_call_method_p5_cache_ex(return_value, NULL, object, method_name, cache, p1, p2, p3, p4, p5) - -#define zephir_call_method_cache_noret(object, method_name, cache) zephir_call_method_p0_cache_ex(NULL, NULL, object, method_name, cache) -#define zephir_call_method_p1_cache_noret(object, method_name, cache, p1) zephir_call_method_p1_cache_ex(NULL, NULL, object, method_name, cache, p1) -#define zephir_call_method_p2_cache_noret(object, method_name, cache, p1, p2) zephir_call_method_p2_cache_ex(NULL, NULL, object, method_name, cache, p1, p2) -#define zephir_call_method_p3_cache_noret(object, method_name, cache, p1, p2, p3) zephir_call_method_p3_cache_ex(NULL, NULL, object, method_name, cache, p1, p2, p3) -#define zephir_call_method_p4_cache_noret(object, method_name, cache, p1, p2, p3, p4) zephir_call_method_p4_cache_ex(NULL, NULL, object, method_name, cache, p1, p2, p3, p4) -#define zephir_call_method_p5_cache_noret(object, method_name, cache, p1, p2, p3, p4, p5) zephir_call_method_p5_cache_ex(NULL, NULL, object, method_name, cache, p1, p2, p3, p4, p5) - -#define zephir_call_method_key(return_value, object, method_name, key) zephir_call_method_p0_key_ex(return_value, NULL, object, method_name, key) -#define zephir_call_method_p1_key(return_value, object, method_name, key, p1) zephir_call_method_p1_key_ex(return_value, NULL, object, method_name, key, p1) -#define zephir_call_method_p2_key(return_value, object, method_name, key, p1, p2) zephir_call_method_p2_key_ex(return_value, NULL, object, method_name, key, p1, p2) -#define zephir_call_method_p3_key(return_value, object, method_name, key, p1, p2, p3) zephir_call_method_p3_key_ex(return_value, NULL, object, method_name, key, p1, p2, p3) -#define zephir_call_method_p4_key(return_value, object, method_name, key, p1, p2, p3, p4) zephir_call_method_p4_key_ex(return_value, NULL, object, method_name, key, p1, p2, p3, p4) -#define zephir_call_method_p5_key(return_value, object, method_name, key, p1, p2, p3, p4, p5) zephir_call_method_p5_key_ex(return_value, NULL, object, method_name, key, p1, p2, p3, p4, p5) +#define zephir_call_method_p6_cache_key_ex(return_value, return_value_ptr, object, method_name, key, cache, p1, p2, p3, p4, p5, p6) \ + do { \ + if (0) { \ + if (Z_TYPE_P(p1)) {} \ + if (Z_TYPE_P(p2)) {} \ + if (Z_TYPE_P(p3)) {} \ + if (Z_TYPE_P(p4)) {} \ + if (Z_TYPE_P(p5)) {} \ + if (Z_TYPE_P(p6)) {} \ + } \ + ZEPHIR_CALL_METHOD_CACHE(return_value, return_value_ptr, object, method_name, key, cache, 5, p1, p2, p3, p4, p5, p6); \ + } while (0) + +#define zephir_call_method_p7_cache_key_ex(return_value, return_value_ptr, object, method_name, key, cache, p1, p2, p3, p4, p5, p6, p7) \ + do { \ + if (0) { \ + if (Z_TYPE_P(p1)) {} \ + if (Z_TYPE_P(p2)) {} \ + if (Z_TYPE_P(p3)) {} \ + if (Z_TYPE_P(p4)) {} \ + if (Z_TYPE_P(p5)) {} \ + if (Z_TYPE_P(p6)) {} \ + if (Z_TYPE_P(p7)) {} \ + } \ + ZEPHIR_CALL_METHOD_CACHE(return_value, return_value_ptr, object, method_name, key, cache, 5, p1, p2, p3, p4, p5, p6, p7); \ + } while (0) + +#define zephir_call_method_p8_cache_key_ex(return_value, return_value_ptr, object, method_name, key, cache, p1, p2, p3, p4, p5, p6, p7, p8) \ + do { \ + if (0) { \ + if (Z_TYPE_P(p1)) {} \ + if (Z_TYPE_P(p2)) {} \ + if (Z_TYPE_P(p3)) {} \ + if (Z_TYPE_P(p4)) {} \ + if (Z_TYPE_P(p5)) {} \ + if (Z_TYPE_P(p6)) {} \ + if (Z_TYPE_P(p7)) {} \ + if (Z_TYPE_P(p8)) {} \ + } \ + ZEPHIR_CALL_METHOD_CACHE(return_value, return_value_ptr, object, method_name, key, cache, 5, p1, p2, p3, p4, p5, p6, p7, p8); \ + } while (0) + +#define zephir_call_method_p0_ex(return_value, return_value_ptr, object, method_name) zephir_call_method_p0_key_ex(return_value, return_value_ptr, object, method_name, 0) +#define zephir_call_method_p1_ex(return_value, return_value_ptr, object, method_name, p1) zephir_call_method_p1_key_ex(return_value, return_value_ptr, object, method_name, 0, p1) +#define zephir_call_method_p2_ex(return_value, return_value_ptr, object, method_name, p1, p2) zephir_call_method_p2_key_ex(return_value, return_value_ptr, object, method_name, 0, p1, p2) +#define zephir_call_method_p3_ex(return_value, return_value_ptr, object, method_name, p1, p2, p3) zephir_call_method_p3_key_ex(return_value, return_value_ptr, object, method_name, 0, p1, p2, p3) +#define zephir_call_method_p4_ex(return_value, return_value_ptr, object, method_name, p1, p2, p3, p4) zephir_call_method_p4_key_ex(return_value, return_value_ptr, object, method_name, 0, p1, p2, p3, p4) +#define zephir_call_method_p5_ex(return_value, return_value_ptr, object, method_name, p1, p2, p3, p4, p5) zephir_call_method_p5_key_ex(return_value, return_value_ptr, object, method_name, 0, p1, p2, p3, p4, p5) +#define zephir_call_method_p6_ex(return_value, return_value_ptr, object, method_name, p1, p2, p3, p4, p5, p6) zephir_call_method_p6_key_ex(return_value, return_value_ptr, object, method_name, 0, p1, p2, p3, p4, p5, p6) +#define zephir_call_method_p7_ex(return_value, return_value_ptr, object, method_name, p1, p2, p3, p4, p5, p6, p7) zephir_call_method_p7_key_ex(return_value, return_value_ptr, object, method_name, 0, p1, p2, p3, p4, p5, p6, p7) +#define zephir_call_method_p8_ex(return_value, return_value_ptr, object, method_name, p1, p2, p3, p4, p5, p6, p7, p8) zephir_call_method_p8_key_ex(return_value, return_value_ptr, object, method_name, 0, p1, p2, p3, p4, p5, p6, p7, p8) + +#define zephir_call_method_p0_cache_ex(return_value, return_value_ptr, object, method_name, cache) zephir_call_method_p0_cache_key_ex(return_value, return_value_ptr, object, method_name, 0, cache) +#define zephir_call_method_p1_cache_ex(return_value, return_value_ptr, object, method_name, cache, p1) zephir_call_method_p1_cache_key_ex(return_value, return_value_ptr, object, method_name, 0, cache, p1) +#define zephir_call_method_p2_cache_ex(return_value, return_value_ptr, object, method_name, cache, p1, p2) zephir_call_method_p2_cache_key_ex(return_value, return_value_ptr, object, method_name, 0, cache, p1, p2) +#define zephir_call_method_p3_cache_ex(return_value, return_value_ptr, object, method_name, cache, p1, p2, p3) zephir_call_method_p3_cache_key_ex(return_value, return_value_ptr, object, method_name, 0, cache, p1, p2, p3) +#define zephir_call_method_p4_cache_ex(return_value, return_value_ptr, object, method_name, cache, p1, p2, p3, p4) zephir_call_method_p4_cache_key_ex(return_value, return_value_ptr, object, method_name, 0, cache, p1, p2, p3, p4) +#define zephir_call_method_p5_cache_ex(return_value, return_value_ptr, object, method_name, cache, p1, p2, p3, p4, p5) zephir_call_method_p5_cache_key_ex(return_value, return_value_ptr, object, method_name, 0, cache, p1, p2, p3, p4, p5) +#define zephir_call_method_p6_cache_ex(return_value, return_value_ptr, object, method_name, cache, p1, p2, p3, p4, p5, p6) zephir_call_method_p6_cache_key_ex(return_value, return_value_ptr, object, method_name, 0, cache, p1, p2, p3, p4, p5, p6) +#define zephir_call_method_p7_cache_ex(return_value, return_value_ptr, object, method_name, cache, p1, p2, p3, p4, p5, p6, p7) zephir_call_method_p7_cache_key_ex(return_value, return_value_ptr, object, method_name, 0, cache, p1, p2, p3, p4, p5, p6, p7) +#define zephir_call_method_p8_cache_ex(return_value, return_value_ptr, object, method_name, cache, p1, p2, p3, p4, p5, p6, p7, p8) zephir_call_method_p8_cache_key_ex(return_value, return_value_ptr, object, method_name, 0, cache, p1, p2, p3, p4, p5, p6, p7, p8) + +#define zephir_call_method(return_value, object, method_name) zephir_call_method_p0_ex(return_value, NULL, object, method_name) +#define zephir_call_method_p1(return_value, object, method_name, p1) zephir_call_method_p1_ex(return_value, NULL, object, method_name, p1) +#define zephir_call_method_p2(return_value, object, method_name, p1, p2) zephir_call_method_p2_ex(return_value, NULL, object, method_name, p1, p2) +#define zephir_call_method_p3(return_value, object, method_name, p1, p2, p3) zephir_call_method_p3_ex(return_value, NULL, object, method_name, p1, p2, p3) +#define zephir_call_method_p4(return_value, object, method_name, p1, p2, p3, p4) zephir_call_method_p4_ex(return_value, NULL, object, method_name, p1, p2, p3, p4) +#define zephir_call_method_p5(return_value, object, method_name, p1, p2, p3, p4, p5) zephir_call_method_p5_ex(return_value, NULL, object, method_name, p1, p2, p3, p4, p5) +#define zephir_call_method_p6(return_value, object, method_name, p1, p2, p3, p4, p5, p6) zephir_call_method_p6_ex(return_value, NULL, object, method_name, p1, p2, p3, p4, p5, p6) +#define zephir_call_method_p7(return_value, object, method_name, p1, p2, p3, p4, p5, p6, p7) zephir_call_method_p7_ex(return_value, NULL, object, method_name, p1, p2, p3, p4, p5, p6, p7) +#define zephir_call_method_p8(return_value, object, method_name, p1, p2, p3, p4, p5, p6, p7, p8) zephir_call_method_p8_ex(return_value, NULL, object, method_name, p1, p2, p3, p4, p5, p6, p7, p8) + +#define zephir_call_method_noret(object, method_name) zephir_call_method_p0_ex(NULL, NULL, object, method_name) +#define zephir_call_method_p1_noret(object, method_name, p1) zephir_call_method_p1_ex(NULL, NULL, object, method_name, p1) +#define zephir_call_method_p2_noret(object, method_name, p1, p2) zephir_call_method_p2_ex(NULL, NULL, object, method_name, p1, p2) +#define zephir_call_method_p3_noret(object, method_name, p1, p2, p3) zephir_call_method_p3_ex(NULL, NULL, object, method_name, p1, p2, p3) +#define zephir_call_method_p4_noret(object, method_name, p1, p2, p3, p4) zephir_call_method_p4_ex(NULL, NULL, object, method_name, p1, p2, p3, p4) +#define zephir_call_method_p5_noret(object, method_name, p1, p2, p3, p4, p5) zephir_call_method_p5_ex(NULL, NULL, object, method_name, p1, p2, p3, p4, p5) +#define zephir_call_method_p6_noret(object, method_name, p1, p2, p3, p4, p5, p6) zephir_call_method_p6_ex(NULL, NULL, object, method_name, p1, p2, p3, p4, p5, p6) +#define zephir_call_method_p7_noret(object, method_name, p1, p2, p3, p4, p5, p6, p7) zephir_call_method_p7_ex(NULL, NULL, object, method_name, p1, p2, p3, p4, p5, p6, p7) +#define zephir_call_method_p8_noret(object, method_name, p1, p2, p3, p4, p5, p6, p7, p8) zephir_call_method_p8_ex(NULL, NULL, object, method_name, p1, p2, p3, p4, p5, p6, p7, p8) + +#define zephir_call_method_cache(return_value, object, method_name, cache) zephir_call_method_p0_cache_ex(return_value, NULL, object, method_name, cache) +#define zephir_call_method_p1_cache(return_value, object, method_name, cache, p1) zephir_call_method_p1_cache_ex(return_value, NULL, object, method_name, cache, p1) +#define zephir_call_method_p2_cache(return_value, object, method_name, cache, p1, p2) zephir_call_method_p2_cache_ex(return_value, NULL, object, method_name, cache, p1, p2) +#define zephir_call_method_p3_cache(return_value, object, method_name, cache, p1, p2, p3) zephir_call_method_p3_cache_ex(return_value, NULL, object, method_name, cache, p1, p2, p3) +#define zephir_call_method_p4_cache(return_value, object, method_name, cache, p1, p2, p3, p4) zephir_call_method_p4_cache_ex(return_value, NULL, object, method_name, cache, p1, p2, p3, p4) +#define zephir_call_method_p5_cache(return_value, object, method_name, cache, p1, p2, p3, p4, p5) zephir_call_method_p5_cache_ex(return_value, NULL, object, method_name, cache, p1, p2, p3, p4, p5) +#define zephir_call_method_p6_cache(return_value, object, method_name, cache, p1, p2, p3, p4, p5, p6) zephir_call_method_p6_cache_ex(return_value, NULL, object, method_name, cache, p1, p2, p3, p4, p5, p6) +#define zephir_call_method_p7_cache(return_value, object, method_name, cache, p1, p2, p3, p4, p5, p6, p7) zephir_call_method_p7_cache_ex(return_value, NULL, object, method_name, cache, p1, p2, p3, p4, p5, p6, p7) +#define zephir_call_method_p8_cache(return_value, object, method_name, cache, p1, p2, p3, p4, p5, p6, p7, p8) zephir_call_method_p8_cache_ex(return_value, NULL, object, method_name, cache, p1, p2, p3, p4, p5, p6, p7, p8) + +#define zephir_call_method_cache_noret(object, method_name, cache) zephir_call_method_p0_cache_ex(NULL, NULL, object, method_name, cache) +#define zephir_call_method_p1_cache_noret(object, method_name, cache, p1) zephir_call_method_p1_cache_ex(NULL, NULL, object, method_name, cache, p1) +#define zephir_call_method_p2_cache_noret(object, method_name, cache, p1, p2) zephir_call_method_p2_cache_ex(NULL, NULL, object, method_name, cache, p1, p2) +#define zephir_call_method_p3_cache_noret(object, method_name, cache, p1, p2, p3) zephir_call_method_p3_cache_ex(NULL, NULL, object, method_name, cache, p1, p2, p3) +#define zephir_call_method_p4_cache_noret(object, method_name, cache, p1, p2, p3, p4) zephir_call_method_p4_cache_ex(NULL, NULL, object, method_name, cache, p1, p2, p3, p4) +#define zephir_call_method_p5_cache_noret(object, method_name, cache, p1, p2, p3, p4, p5) zephir_call_method_p5_cache_ex(NULL, NULL, object, method_name, cache, p1, p2, p3, p4, p5) +#define zephir_call_method_p6_cache_noret(object, method_name, cache, p1, p2, p3, p4, p5, p6) zephir_call_method_p6_cache_ex(NULL, NULL, object, method_name, cache, p1, p2, p3, p4, p5, p6) +#define zephir_call_method_p7_cache_noret(object, method_name, cache, p1, p2, p3, p4, p5, p6, p7) zephir_call_method_p7_cache_ex(NULL, NULL, object, method_name, cache, p1, p2, p3, p4, p5, p6, p7) +#define zephir_call_method_p8_cache_noret(object, method_name, cache, p1, p2, p3, p4, p5, p6, p7, p8) zephir_call_method_p8_cache_ex(NULL, NULL, object, method_name, cache, p1, p2, p3, p4, p5, p6, p7, p8) + +#define zephir_call_method_key(return_value, object, method_name, key) zephir_call_method_p0_key_ex(return_value, NULL, object, method_name, key) +#define zephir_call_method_p1_key(return_value, object, method_name, key, p1) zephir_call_method_p1_key_ex(return_value, NULL, object, method_name, key, p1) +#define zephir_call_method_p2_key(return_value, object, method_name, key, p1, p2) zephir_call_method_p2_key_ex(return_value, NULL, object, method_name, key, p1, p2) +#define zephir_call_method_p3_key(return_value, object, method_name, key, p1, p2, p3) zephir_call_method_p3_key_ex(return_value, NULL, object, method_name, key, p1, p2, p3) +#define zephir_call_method_p4_key(return_value, object, method_name, key, p1, p2, p3, p4) zephir_call_method_p4_key_ex(return_value, NULL, object, method_name, key, p1, p2, p3, p4) +#define zephir_call_method_p5_key(return_value, object, method_name, key, p1, p2, p3, p4, p5) zephir_call_method_p5_key_ex(return_value, NULL, object, method_name, key, p1, p2, p3, p4, p5) +#define zephir_call_method_p6_key(return_value, object, method_name, key, p1, p2, p3, p4, p5, p6) zephir_call_method_p6_key_ex(return_value, NULL, object, method_name, key, p1, p2, p3, p4, p5, p6) +#define zephir_call_method_p7_key(return_value, object, method_name, key, p1, p2, p3, p4, p5, p6, p7) zephir_call_method_p7_key_ex(return_value, NULL, object, method_name, key, p1, p2, p3, p4, p5, p6, p7) +#define zephir_call_method_p8_key(return_value, object, method_name, key, p1, p2, p3, p4, p5, p6, p7, p8) zephir_call_method_p8_key_ex(return_value, NULL, object, method_name, key, p1, p2, p3, p4, p5, p6, p7, p8) /** Macros to call methods with zvals as method names */ -#define zephir_call_method_zval(return_value, object, method) ZEPHIR_CALL_ZMETHOD(return_value, NULL, object, method, 0, NULL) -#define zephir_call_method_zval_p1(return_value, object, method, p1) ZEPHIR_CALL_ZMETHOD(return_value, NULL, object, method, 1, p1) -#define zephir_call_method_zval_p2(return_value, object, method, p1, p2) ZEPHIR_CALL_ZMETHOD(return_value, NULL, object, method, 2, p1, p2) -#define zephir_call_method_zval_p3(return_value, object, method, p1, p2, p3) ZEPHIR_CALL_ZMETHOD(return_value, NULL, object, method, 3, p1, p2, p3) +#define zephir_call_method_zval(return_value, object, method) ZEPHIR_CALL_ZMETHOD(return_value, NULL, object, method, 0, NULL) +#define zephir_call_method_zval_p1(return_value, object, method, p1) ZEPHIR_CALL_ZMETHOD(return_value, NULL, object, method, 1, p1) +#define zephir_call_method_zval_p2(return_value, object, method, p1, p2) ZEPHIR_CALL_ZMETHOD(return_value, NULL, object, method, 2, p1, p2) +#define zephir_call_method_zval_p3(return_value, object, method, p1, p2, p3) ZEPHIR_CALL_ZMETHOD(return_value, NULL, object, method, 3, p1, p2, p3) -#define zephir_call_method_zval_noret(object, method) ZEPHIR_CALL_ZMETHOD(NULL, NULL, object, method, 0, NULL) -#define zephir_call_method_zval_p1_noret(object, method, p1) ZEPHIR_CALL_ZMETHOD(NULL, NULL, object, method, 1, p1) -#define zephir_call_method_zval_p2_noret(object, method, p1, p2) ZEPHIR_CALL_ZMETHOD(NULL, NULL, object, method, 2, p1, p2) -#define zephir_call_method_zval_p3_noret(object, method, p1, p2, p3) ZEPHIR_CALL_ZMETHOD(NULL, NULL, object, method, 3, p1, p2, p3) +#define zephir_call_method_zval_noret(object, method) ZEPHIR_CALL_ZMETHOD(NULL, NULL, object, method, 0, NULL) +#define zephir_call_method_zval_p1_noret(object, method, p1) ZEPHIR_CALL_ZMETHOD(NULL, NULL, object, method, 1, p1) +#define zephir_call_method_zval_p2_noret(object, method, p1, p2) ZEPHIR_CALL_ZMETHOD(NULL, NULL, object, method, 2, p1, p2) +#define zephir_call_method_zval_p3_noret(object, method, p1, p2, p3) ZEPHIR_CALL_ZMETHOD(NULL, NULL, object, method, 3, p1, p2, p3) /** Use these macros to call functions in the parent class */ -#define zephir_call_parent(return_value, object, active_class, method) ZEPHIR_CALL_PARENT(return_value, NULL, object, active_class, method, 0, NULL) -#define zephir_call_parent_p1(return_value, object, active_class, method, p1) ZEPHIR_CALL_PARENT(return_value, NULL, object, active_class, method, 1, p1) -#define zephir_call_parent_p2(return_value, object, active_class, method, p1, p2) ZEPHIR_CALL_PARENT(return_value, NULL, object, active_class, method, 2, p1, p2) - -#define zephir_call_parent_noret(object, active_class, method) ZEPHIR_CALL_PARENT(NULL, NULL, object, active_class, method, 0, NULL) -#define zephir_call_parent_p1_noret(object, active_class, method, p1) ZEPHIR_CALL_PARENT(NULL, NULL, object, active_class, method, 1, p1) -#define zephir_call_parent_p2_noret(object, active_class, method, p1, p2) ZEPHIR_CALL_PARENT(NULL, NULL, object, active_class, method, 2, p1, p2) -#define zephir_call_parent_p3_noret(object, active_class, method, p1, p2, p3) ZEPHIR_CALL_PARENT(NULL, NULL, object, active_class, method, 3, p1, p2, p3) -#define zephir_call_parent_p4_noret(object, active_class, method, p1, p2, p3, p4) ZEPHIR_CALL_PARENT(NULL, NULL, object, active_class, method, 4, p1, p2, p3, p4) -#define zephir_call_parent_p5_noret(object, active_class, method, p1, p2, p3, p4, p5) ZEPHIR_CALL_PARENT(NULL, NULL, object, active_class, method, 5, p1, p2, p3, p4, p5) +#define zephir_call_parent(return_value, object, active_class, method) ZEPHIR_CALL_PARENT(return_value, NULL, object, active_class, method, 0, NULL) +#define zephir_call_parent_p1(return_value, object, active_class, method, p1) ZEPHIR_CALL_PARENT(return_value, NULL, object, active_class, method, 1, p1) +#define zephir_call_parent_p2(return_value, object, active_class, method, p1, p2) ZEPHIR_CALL_PARENT(return_value, NULL, object, active_class, method, 2, p1, p2) + +#define zephir_call_parent_noret(object, active_class, method) ZEPHIR_CALL_PARENT(NULL, NULL, object, active_class, method, 0, NULL) +#define zephir_call_parent_p1_noret(object, active_class, method, p1) ZEPHIR_CALL_PARENT(NULL, NULL, object, active_class, method, 1, p1) +#define zephir_call_parent_p2_noret(object, active_class, method, p1, p2) ZEPHIR_CALL_PARENT(NULL, NULL, object, active_class, method, 2, p1, p2) +#define zephir_call_parent_p3_noret(object, active_class, method, p1, p2, p3) ZEPHIR_CALL_PARENT(NULL, NULL, object, active_class, method, 3, p1, p2, p3) +#define zephir_call_parent_p4_noret(object, active_class, method, p1, p2, p3, p4) ZEPHIR_CALL_PARENT(NULL, NULL, object, active_class, method, 4, p1, p2, p3, p4) +#define zephir_call_parent_p5_noret(object, active_class, method, p1, p2, p3, p4, p5) ZEPHIR_CALL_PARENT(NULL, NULL, object, active_class, method, 5, p1, p2, p3, p4, p5) +#define zephir_call_parent_p6_noret(object, active_class, method, p1, p2, p3, p4, p5, p6) ZEPHIR_CALL_PARENT(NULL, NULL, object, active_class, method, 6, p1, p2, p3, p4, p5, p6) +#define zephir_call_parent_p7_noret(object, active_class, method, p1, p2, p3, p4, p5, p6, p7) ZEPHIR_CALL_PARENT(NULL, NULL, object, active_class, method, 7, p1, p2, p3, p4, p5, p6, p7) +#define zephir_call_parent_p8_noret(object, active_class, method, p1, p2, p3, p4, p5, p6, p7, p8) ZEPHIR_CALL_PARENT(NULL, NULL, object, active_class, method, 8, p1, p2, p3, p4, p5, p6, p7, p8) /** Use these functions to call static functions on the current class */ -#define zephir_call_self(return_value, object, method) ZEPHIR_CALL_SELF(return_value, NULL, object, method, 0, NULL) -#define zephir_call_self_p1(return_value, object, method, p1) ZEPHIR_CALL_SELF(return_value, NULL, object, method, 1, p1) -#define zephir_call_self_p2(return_value, object, method, p1, p2) ZEPHIR_CALL_SELF(return_value, NULL, object, method, 2, p1, p2) -#define zephir_call_self_p3(return_value, object, method, p1, p2, p3) ZEPHIR_CALL_SELF(return_value, NULL, object, method, 3, p1, p2, p3) -#define zephir_call_self_p4(return_value, object, method, p1, p2, p3, p4) ZEPHIR_CALL_SELF(return_value, NULL, object, method, 4, p1, p2, p3, p4) - -#define zephir_call_self_noret(object, method, param_count, params) ZEPHIR_CALL_SELF(NULL, NULL, object, method, 0, NULL) -#define zephir_call_self_p1_noret(object, method, p1) ZEPHIR_CALL_SELF(NULL, NULL, object, method, 1, p1) -#define zephir_call_self_p2_noret(object, method, p1, p2) ZEPHIR_CALL_SELF(NULL, NULL, object, method, 2, p1, p2) -#define zephir_call_self_p3_noret(object, method, p1, p2, p3) ZEPHIR_CALL_SELF(NULL, NULL, object, method, 3, p1, p2, p3) -#define zephir_call_self_p4_noret(object, method, p1, p2, p3, p4) ZEPHIR_CALL_SELF(NULL, NULL, object, method, 4, p1, p2, p3, p4) +#define zephir_call_self(return_value, object, method) ZEPHIR_CALL_SELF(return_value, NULL, object, method, 0, NULL) +#define zephir_call_self_p1(return_value, object, method, p1) ZEPHIR_CALL_SELF(return_value, NULL, object, method, 1, p1) +#define zephir_call_self_p2(return_value, object, method, p1, p2) ZEPHIR_CALL_SELF(return_value, NULL, object, method, 2, p1, p2) +#define zephir_call_self_p3(return_value, object, method, p1, p2, p3) ZEPHIR_CALL_SELF(return_value, NULL, object, method, 3, p1, p2, p3) +#define zephir_call_self_p4(return_value, object, method, p1, p2, p3, p4) ZEPHIR_CALL_SELF(return_value, NULL, object, method, 4, p1, p2, p3, p4) + +#define zephir_call_self_noret(object, method, param_count, params) ZEPHIR_CALL_SELF(NULL, NULL, object, method, 0, NULL) +#define zephir_call_self_p1_noret(object, method, p1) ZEPHIR_CALL_SELF(NULL, NULL, object, method, 1, p1) +#define zephir_call_self_p2_noret(object, method, p1, p2) ZEPHIR_CALL_SELF(NULL, NULL, object, method, 2, p1, p2) +#define zephir_call_self_p3_noret(object, method, p1, p2, p3) ZEPHIR_CALL_SELF(NULL, NULL, object, method, 3, p1, p2, p3) +#define zephir_call_self_p4_noret(object, method, p1, p2, p3, p4) ZEPHIR_CALL_SELF(NULL, NULL, object, method, 4, p1, p2, p3, p4) /** Use these macros to call functions statically */ -#define zephir_call_static(return_value, class_name, method_name) ZEPHIR_CALL_STATIC(return_value, NULL, class_name, method_name, 0, NULL) -#define zephir_call_static_p1(return_value, class_name, method_name, p1) ZEPHIR_CALL_STATIC(return_value, NULL, class_name, method_name, 1, p1) -#define zephir_call_static_p2(return_value, class_name, method_name, p1, p2) ZEPHIR_CALL_STATIC(return_value, NULL, class_name, method_name, 2, p1, p2) -#define zephir_call_static_p3(return_value, class_name, method_name, p1, p2, p3) ZEPHIR_CALL_STATIC(return_value, NULL, class_name, method_name, 3, p1, p2, p3) -#define zephir_call_static_p4(return_value, class_name, method_name, p1, p2, p3, p4) ZEPHIR_CALL_STATIC(return_value, NULL, class_name, method_name, 4, p1, p2, p3, p4) -#define zephir_call_static_p5(return_value, class_name, method_name, p1, p2, p3, p4, p5) ZEPHIR_CALL_STATIC(return_value, NULL, class_name, method_name, 5, p1, p2, p3, p4, p5) - -#define zephir_call_static_noret(class_name, method_name) ZEPHIR_CALL_STATIC(NULL, NULL, class_name, method_name, 0, NULL) -#define zephir_call_static_p1_noret(class_name, method_name, p1) ZEPHIR_CALL_STATIC(NULL, NULL, class_name, method_name, 1, p1) -#define zephir_call_static_p2_noret(class_name, method_name, p1, p2) ZEPHIR_CALL_STATIC(NULL, NULL, class_name, method_name, 2, p1, p2) -#define zephir_call_static_p3_noret(class_name, method_name, p1, p2, p3) ZEPHIR_CALL_STATIC(NULL, NULL, class_name, method_name, 3, p1, p2, p3) -#define zephir_call_static_p4_noret(class_name, method_name, p1, p2, p3, p4) ZEPHIR_CALL_STATIC(NULL, NULL, class_name, method_name, 4, p1, p2, p3, p4) -#define zephir_call_static_p5_noret(class_name, method_name, p1, p2, p3, p4, p5) ZEPHIR_CALL_STATIC(NULL, NULL, class_name, method_name, 5, p1, p2, p3, p4, p5) - - -#define zephir_call_zval_static(return_value, class_zval, method) ZEPHIR_CALL_ZSTATIC(return_value, NULL, class_zval, method, 0, NULL) -#define zephir_call_zval_static_p1(return_value, class_zval, method, p1) ZEPHIR_CALL_ZSTATIC(return_value, NULL, class_zval, method, 1, p1) +#define zephir_call_static(return_value, class_name, method_name) ZEPHIR_CALL_STATIC(return_value, NULL, class_name, method_name, 0, NULL) +#define zephir_call_static_p1(return_value, class_name, method_name, p1) ZEPHIR_CALL_STATIC(return_value, NULL, class_name, method_name, 1, p1) +#define zephir_call_static_p2(return_value, class_name, method_name, p1, p2) ZEPHIR_CALL_STATIC(return_value, NULL, class_name, method_name, 2, p1, p2) +#define zephir_call_static_p3(return_value, class_name, method_name, p1, p2, p3) ZEPHIR_CALL_STATIC(return_value, NULL, class_name, method_name, 3, p1, p2, p3) +#define zephir_call_static_p4(return_value, class_name, method_name, p1, p2, p3, p4) ZEPHIR_CALL_STATIC(return_value, NULL, class_name, method_name, 4, p1, p2, p3, p4) +#define zephir_call_static_p5(return_value, class_name, method_name, p1, p2, p3, p4, p5) ZEPHIR_CALL_STATIC(return_value, NULL, class_name, method_name, 5, p1, p2, p3, p4, p5) + +#define zephir_call_static_noret(class_name, method_name) ZEPHIR_CALL_STATIC(NULL, NULL, class_name, method_name, 0, NULL) +#define zephir_call_static_p1_noret(class_name, method_name, p1) ZEPHIR_CALL_STATIC(NULL, NULL, class_name, method_name, 1, p1) +#define zephir_call_static_p2_noret(class_name, method_name, p1, p2) ZEPHIR_CALL_STATIC(NULL, NULL, class_name, method_name, 2, p1, p2) +#define zephir_call_static_p3_noret(class_name, method_name, p1, p2, p3) ZEPHIR_CALL_STATIC(NULL, NULL, class_name, method_name, 3, p1, p2, p3) +#define zephir_call_static_p4_noret(class_name, method_name, p1, p2, p3, p4) ZEPHIR_CALL_STATIC(NULL, NULL, class_name, method_name, 4, p1, p2, p3, p4) +#define zephir_call_static_p5_noret(class_name, method_name, p1, p2, p3, p4, p5) ZEPHIR_CALL_STATIC(NULL, NULL, class_name, method_name, 5, p1, p2, p3, p4, p5) + + +#define zephir_call_zval_static(return_value, class_zval, method) ZEPHIR_CALL_ZSTATIC(return_value, NULL, class_zval, method, 0, NULL) +#define zephir_call_zval_static_p1(return_value, class_zval, method, p1) ZEPHIR_CALL_ZSTATIC(return_value, NULL, class_zval, method, 1, p1) #define zephir_call_zval_str_static_p1(return_value, class_zval, method, p1) ZEPHIR_CALL_ZSTATIC_STR(return_value, NULL, class_zval, method, 1, p1) diff --git a/parser/scanner.re b/parser/scanner.re index c8fcad5d050..b95cf064536 100755 --- a/parser/scanner.re +++ b/parser/scanner.re @@ -515,6 +515,11 @@ int xx_get_token(xx_scanner_state *s, xx_scanner_token *token) { return 0; } + if (!memcmp(token->value, "_COOKIE", sizeof("_COOKIE")-1)) { + token->opcode = XX_T_IDENTIFIER; + return 0; + } + if (!memcmp(token->value, "_SERVER", sizeof("_SERVER")-1)) { token->opcode = XX_T_IDENTIFIER; return 0;