Skip to content

Commit

Permalink
Updated build script
Browse files Browse the repository at this point in the history
  • Loading branch information
sjinks committed Aug 1, 2013
1 parent e5c680d commit beba42b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 73 deletions.
7 changes: 7 additions & 0 deletions ext/kernel/fcall.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,13 @@
#define phalcon_call_method_p4_noret(object, method_name, p1, p2, p3, p4) PHALCON_CALL_METHOD(NULL, object, method_name, 0, 4, p1, p2, p3, p4)
#define phalcon_call_method_p5_noret(object, method_name, p1, p2, p3, p4, p5) PHALCON_CALL_METHOD(NULL, object, method_name, 0, 5, p1, p2, p3, p4, p5)

#define phalcon_call_method_key(return_value, object, method_name, key) PHALCON_CALL_METHOD(return_value, object, method_name, key, 0, NULL)
#define phalcon_call_method_p1_key(return_value, object, method_name, key, p1) PHALCON_CALL_METHOD(return_value, object, method_name, key, 1, p1)
#define phalcon_call_method_p2_key(return_value, object, method_name, key, p1, p2) PHALCON_CALL_METHOD(return_value, object, method_name, key, 2, p1, p2)
#define phalcon_call_method_p3_key(return_value, object, method_name, key, p1, p2, p3) PHALCON_CALL_METHOD(return_value, object, method_name, key, 3, p1, p2, p3)
#define phalcon_call_method_p4_key(return_value, object, method_name, key, p1, p2, p3, p4) PHALCON_CALL_METHOD(return_value, object, method_name, key, 4, p1, p2, p3, p4)
#define phalcon_call_method_p5_key(return_value, object, method_name, key, p1, p2, p3, p4, p5) PHALCON_CALL_METHOD(return_value, object, method_name, key, 5, p1, p2, p3, p4, p5)

/** Macros to call methods with zvals as method names */
#define phalcon_call_method_zval(return_value, object, method) PHALCON_CALL_ZMETHOD(return_value, object, method, 0, NULL)
#define phalcon_call_method_zval_p1(return_value, object, method, p1) PHALCON_CALL_ZMETHOD(return_value, object, method, 1, p1)
Expand Down
91 changes: 18 additions & 73 deletions scripts/gen-build.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ public function generate($path, $destination='build/', $calculateHashKeys=false,
#include "ext/standard/head.h"
#include "ext/standard/url.h"
#include "ext/spl/spl_heap.h"
#include "ext/date/php_date.h"
#ifdef PHALCON_USE_PHP_PCRE
#include "ext/pcre/php_pcre.h"
Expand Down Expand Up @@ -354,6 +355,14 @@ private function _appendSource($path)
if ($this->_calculateHashKeys) {
$hash = $this->_hash;

/* Explicit calls to zend_inline_hash_func() */
if (preg_match('/(zend_inline_hash_func\(SS\("([^"]++)"\)\))/', $line, $matches)) {
$key = Phalcon\Kernel::$hash($matches[2]) . 'UL';
$line = str_replace($matches[1], $key, $line);
fputs($fileHandler, $line);
continue;
}

/**
* Pre-compute the hash key for isset using strings
*/
Expand Down Expand Up @@ -395,7 +404,7 @@ private function _appendSource($path)
}

/**
* Pre-compute hash key for method checking
* Pre-compute hash key for function checking
*/
if (preg_match('/phalcon_function_exists_ex\(SS\("([a-zA-Z\_\-]+)"\) TSRMLS_CC\)/', $line, $matches)) {
$key = Phalcon\Kernel::$hash($matches[1]);
Expand All @@ -404,82 +413,18 @@ private function _appendSource($path)
continue;
}

/**
* Pre-compute hashes for method calls
*/
if (preg_match('/phalcon_call_method\(([a-zA-Z0-9\_]+), ([a-zA-Z0-9\_]+), "([a-zA-Z0-9\_]+)"\)/', $line, $matches)) {
$key = Phalcon\Kernel::$hash($matches[3]);
$line = str_replace($matches[0], 'phalcon_call_method_key('.$matches[1].', '.$matches[2].', "'.$matches[3].'", '.$key.'UL)', $line);
fputs($fileHandler, $line);
continue;
}

if (preg_match('/phalcon_call_method_noret\(([a-zA-Z0-9\_]+), "([a-zA-Z0-9\_]+)"\)/', $line, $matches)) {
$key = Phalcon\Kernel::$hash($matches[2]);
$line = str_replace($matches[0], 'phalcon_call_method_key(NULL, '.$matches[1].', "'.$matches[2].'", '.$key.'UL)', $line);
fputs($fileHandler, $line);
continue;
}

if (preg_match('/phalcon_call_method_p1_noret\(([a-zA-Z0-9\_]+), "([a-zA-Z0-9\_]+)", ([a-zA-Z0-9\_]+)\)/', $line, $matches)) {
$key = Phalcon\Kernel::$hash($matches[2]);
$line = str_replace($matches[0], 'phalcon_call_method_p1_key(NULL, '.$matches[1].', "'.$matches[2].'", '.$matches[3].', '.$key.'UL)', $line);
fputs($fileHandler, $line);
continue;
}

if (preg_match('/phalcon_call_method_p1\(([a-zA-Z0-9\_]+), ([a-zA-Z0-9\_]+), "([a-zA-Z0-9\_]+)", ([a-zA-Z0-9\_]+)\)/', $line, $matches)) {
$key = Phalcon\Kernel::$hash($matches[3]);
$line = str_replace($matches[0], 'phalcon_call_method_p1_key('.$matches[1].', '.$matches[2].', "'.$matches[3].'", '.$matches[4].', '.$key.'UL)', $line);
fputs($fileHandler, $line);
continue;
}

if (preg_match('/phalcon_call_method_p2_noret\(([a-zA-Z0-9\_]+), "([a-zA-Z0-9\_]+)", ([a-zA-Z0-9\_]+), ([a-zA-Z0-9\_]+)\)/', $line, $matches)) {
$key = Phalcon\Kernel::$hash($matches[2]);
$line = str_replace($matches[0], 'phalcon_call_method_p2_key(NULL, '.$matches[1].', "'.$matches[2].'", '.$matches[3].', '.$matches[4].', '.$key.'UL)', $line);
fputs($fileHandler, $line);
continue;
}

if (preg_match('/phalcon_call_method_p2\(([a-zA-Z0-9\_]+), ([a-zA-Z0-9\_]+), "([a-zA-Z0-9\_]+)", ([a-zA-Z0-9\_]+), ([a-zA-Z0-9\_]+)\)/', $line, $matches)) {
$key = Phalcon\Kernel::$hash($matches[3]);
$line = str_replace($matches[0], 'phalcon_call_method_p2_key('.$matches[1].', '.$matches[2].', "'.$matches[3].'", '.$matches[4].', '.$matches[5].', '.$key.'UL)', $line);
fputs($fileHandler, $line);
continue;
}

if (preg_match('/phalcon_call_method_p3_noret\(([a-zA-Z0-9\_]+), "([a-zA-Z0-9\_]+)", ([a-zA-Z0-9\_]+), ([a-zA-Z0-9\_]+), ([a-zA-Z0-9\_]+)\)/', $line, $matches)) {
$key = Phalcon\Kernel::$hash($matches[2]);
$line = str_replace($matches[0], 'phalcon_call_method_p3_key(NULL, '.$matches[1].', "'.$matches[2].'", '.$matches[3].', '.$matches[4].', '.$matches[5].', '.$key.'UL)', $line);
/* phalcon_all_method, phalcon_all_method_pX */
if (preg_match('/(phalcon_call_method(?:_p[0-9]+)?)\([a-zA-Z0-9\_]+, [a-zA-Z0-9\_]+, ("[a-zA-Z0-9\_]+")/', $line, $matches)) {
$matches[1] = $matches[1] . '_key';
$matches[2] = $matches[2] . ', ' . Phalcon\Kernel::$hash(substr($matches[2], -1, 1)) . 'UL';
fputs($fileHandler, $line);
continue;
}

if (preg_match('/phalcon_call_method_p3\(([a-zA-Z0-9\_]+), ([a-zA-Z0-9\_]+), "([a-zA-Z0-9\_]+)", ([a-zA-Z0-9\_]+), ([a-zA-Z0-9\_]+), ([a-zA-Z0-9\_]+)\)/', $line, $matches)) {
$key = Phalcon\Kernel::$hash($matches[3]);
$line = str_replace($matches[0], 'phalcon_call_method_p3_key('.$matches[1].', '.$matches[2].', "'.$matches[3].'", '.$matches[4].', '.$matches[5].', '.$matches[6].', '.$key.'UL)', $line);
fputs($fileHandler, $line);
continue;
}

if (preg_match('/phalcon_call_method_p4_noret\(([a-zA-Z0-9\_]+), "([a-zA-Z0-9\_]+)", ([a-zA-Z0-9\_]+), ([a-zA-Z0-9\_]+), ([a-zA-Z0-9\_]+), ([a-zA-Z0-9\_]+)\)/', $line, $matches)) {
$key = Phalcon\Kernel::$hash($matches[2]);
$line = str_replace($matches[0], 'phalcon_call_method_p4_key(NULL, '.$matches[1].', "'.$matches[2].'", '.$matches[3].', '.$matches[4].', '.$matches[5].', '.$matches[6].', '.$key.'UL)', $line);
fputs($fileHandler, $line);
continue;
}

if (preg_match('/phalcon_call_method_p4\(([a-zA-Z0-9\_]+), ([a-zA-Z0-9\_]+), "([a-zA-Z0-9\_]+)", ([a-zA-Z0-9\_]+), ([a-zA-Z0-9\_]+), ([a-zA-Z0-9\_]+), ([a-zA-Z0-9\_]+)\)/', $line, $matches)) {
$key = Phalcon\Kernel::$hash($matches[3]);
$line = str_replace($matches[0], 'phalcon_call_method_p4_key('.$matches[1].', '.$matches[2].', "'.$matches[3].'", '.$matches[4].', '.$matches[5].', '.$matches[6].', '.$matches[7].', '.$key.'UL)', $line);
fputs($fileHandler, $line);
continue;
}

if (preg_match('/phalcon_call_method_p5_noret\(([a-zA-Z0-9\_]+), "([a-zA-Z0-9\_]+)", ([a-zA-Z0-9\_]+), ([a-zA-Z0-9\_]+), ([a-zA-Z0-9\_]+), ([a-zA-Z0-9\_]+), ([a-zA-Z0-9\_]+)\)/', $line, $matches)) {
$key = Phalcon\Kernel::$hash($matches[2]);
$line = str_replace($matches[0], 'phalcon_call_method_p5_key(NULL, '.$matches[1].', "'.$matches[2].'", '.$matches[3].', '.$matches[4].', '.$matches[5].', '.$matches[6].', '.$matches[7].', '.$key.'UL)', $line);
/* phalcon_all_method_noret, phalcon_all_method_pX_noret */
if (preg_match('/phalcon_call_method(?:_p[0-9]+)?(_noret\()[a-zA-Z0-9\_]+, ("[a-zA-Z0-9\_]+")/', $line, $matches)) {
$matches[1] = '_key(NULL, ';
$matches[2] = $matches[2] . ', ' . Phalcon\Kernel::$hash(substr($matches[2], -1, 1)) . 'UL';
fputs($fileHandler, $line);
continue;
}
Expand Down

0 comments on commit beba42b

Please sign in to comment.