1
0
Fork 0

refactor: move functions to module

git-svn-id: svn://svn.lighttpd.net/xcache/trunk@993 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
This commit is contained in:
Xuefer 2012-07-18 08:27:29 +00:00
parent 619a40cb85
commit 689e78da76
5 changed files with 61 additions and 47 deletions

View File

@ -10,3 +10,8 @@ PHP_FUNCTION(xcache_coverager_decode);
PHP_FUNCTION(xcache_coverager_start);
PHP_FUNCTION(xcache_coverager_stop);
PHP_FUNCTION(xcache_coverager_get);
#define XCACHE_COVERAGER_FUNCTIONS() \
PHP_FE(xcache_coverager_decode, NULL) \
PHP_FE(xcache_coverager_start, NULL) \
PHP_FE(xcache_coverager_stop, NULL) \
PHP_FE(xcache_coverager_get, NULL)

View File

@ -118,9 +118,8 @@ typedef struct xc_dasm_sandboxed_t { /* {{{ */
} input;
zval *output;
} xc_dasm_sandboxed_t; /* {{{ */
zend_op_array *xc_dasm_sandboxed(void *data TSRMLS_DC)
} xc_dasm_sandboxed_t; /* }}} */
zend_op_array *xc_dasm_sandboxed(void *data TSRMLS_DC) /* {{{ */
{
zend_bool catched = 0;
zend_op_array *op_array = NULL;
@ -188,3 +187,31 @@ void xc_dasm_file(zval *output, const char *filename TSRMLS_DC) /* {{{ */
FREE_ZVAL(zfilename);
}
/* }}} */
/* {{{ proto array xcache_dasm_file(string filename)
Disassemble file into opcode array by filename */
PHP_FUNCTION(xcache_dasm_file)
{
char *filename;
int filename_len;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) {
return;
}
if (!filename_len) RETURN_FALSE;
xc_dasm_file(return_value, filename TSRMLS_CC);
}
/* }}} */
/* {{{ proto array xcache_dasm_string(string code)
Disassemble php code into opcode array */
PHP_FUNCTION(xcache_dasm_string)
{
zval *code;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &code) == FAILURE) {
return;
}
xc_dasm_string(return_value, code TSRMLS_CC);
}
/* }}} */

View File

@ -1,4 +1,7 @@
#include "php.h"
void xc_dasm_string(zval *return_value, zval *code TSRMLS_DC);
void xc_dasm_file(zval *return_value, const char *filename TSRMLS_DC);
PHP_FUNCTION(xcache_dasm_file);
PHP_FUNCTION(xcache_dasm_string);
#define XCACHE_DISASSEMBLER_FUNCTIONS() \
PHP_FE(xcache_dasm_file, NULL) \
PHP_FE(xcache_dasm_string, NULL)

View File

@ -2,3 +2,4 @@
#include "xcache.h"
void xc_optimizer_op_array_handler(zend_op_array *op_array);
#define XCACHE_OPTIMIZER_FUNCTIONS()

View File

@ -26,9 +26,23 @@
#ifdef ZEND_ENGINE_2_1
#include "ext/date/php_date.h"
#endif
#include "submodules/xc_optimizer.h"
#include "submodules/xc_coverager.h"
#include "submodules/xc_disassembler.h"
#ifdef HAVE_XCACHE_OPTIMIZER
# include "submodules/xc_optimizer.h"
#else
# define XCACHE_OPTIMIZER_FUNCTIONS()
#endif
#ifdef HAVE_XCACHE_COVERAGER
# include "submodules/xc_coverager.h"
#else
# define XCACHE_COVERAGER_FUNCTIONS()
#endif
#ifdef HAVE_XCACHE_DISASSEMBLER
# include "submodules/xc_disassembler.h"
#else
# define XCACHE_DISASSEMBLER_FUNCTIONS()
#endif
#include "xcache_globals.h"
#include "xc_processor.h"
#include "xcache/xc_const_string.h"
@ -3172,35 +3186,6 @@ PHP_FUNCTION(xcache_asm)
}
#endif
/* }}} */
#ifdef HAVE_XCACHE_DISASSEMBLER
/* {{{ proto array xcache_dasm_file(string filename)
Disassemble file into opcode array by filename */
PHP_FUNCTION(xcache_dasm_file)
{
char *filename;
int filename_len;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) {
return;
}
if (!filename_len) RETURN_FALSE;
xc_dasm_file(return_value, filename TSRMLS_CC);
}
/* }}} */
/* {{{ proto array xcache_dasm_string(string code)
Disassemble php code into opcode array */
PHP_FUNCTION(xcache_dasm_string)
{
zval *code;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &code) == FAILURE) {
return;
}
xc_dasm_string(return_value, code TSRMLS_CC);
}
/* }}} */
#endif
/* {{{ proto string xcache_encode(string filename)
Encode php file into XCache opcode encoded format */
#ifdef HAVE_XCACHE_ENCODER
@ -3373,13 +3358,11 @@ static zend_function_entry xcache_functions[] = /* {{{ */
PHP_FE(xcache_list, NULL)
PHP_FE(xcache_clear_cache, NULL)
PHP_FE(xcache_coredump, NULL)
XCACHE_OPTIMIZER_FUNCTIONS()
#ifdef HAVE_XCACHE_ASSEMBLER
PHP_FE(xcache_asm, NULL)
#endif
#ifdef HAVE_XCACHE_DISASSEMBLER
PHP_FE(xcache_dasm_file, NULL)
PHP_FE(xcache_dasm_string, NULL)
#endif
XCACHE_DISASSEMBLER_FUNCTIONS()
#ifdef HAVE_XCACHE_ENCODER
PHP_FE(xcache_encode, NULL)
#endif
@ -3387,12 +3370,7 @@ static zend_function_entry xcache_functions[] = /* {{{ */
PHP_FE(xcache_decode_file, NULL)
PHP_FE(xcache_decode_string, NULL)
#endif
#ifdef HAVE_XCACHE_COVERAGER
PHP_FE(xcache_coverager_decode, NULL)
PHP_FE(xcache_coverager_start, NULL)
PHP_FE(xcache_coverager_stop, NULL)
PHP_FE(xcache_coverager_get, NULL)
#endif
XCACHE_COVERAGER_FUNCTIONS()
PHP_FE(xcache_get_special_value, NULL)
PHP_FE(xcache_get_type, NULL)
PHP_FE(xcache_get_op_type, NULL)