本文整理匯總了C++中CG函數的典型用法代碼示例。如果您正苦於以下問題:C++ CG函數的具體用法?C++ CG怎麽用?C++ CG使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了CG函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: cpGetConfig
zval * cpGetConfig(char *filename) {
zval fun_name, **args[2], *retval, *file, *section;
ZVAL_STRING(&fun_name, "parse_ini_file", 0);
MAKE_STD_ZVAL(file);
ZVAL_STRING(file, filename, 1);
MAKE_STD_ZVAL(section);
ZVAL_BOOL(section, 1);
args[0] = &file;
args[1] = §ion;
if (call_user_function_ex(CG(function_table), NULL, &fun_name, &retval, 2, args, 0, NULL TSRMLS_CC) != SUCCESS)
{
zval_ptr_dtor(&file);
zval_ptr_dtor(§ion);
return NULL;
}
zval_ptr_dtor(&file);
zval_ptr_dtor(§ion);
return retval;
}
示例2: cpMD5
CPINLINE zval * cpMD5(zval *arr) {//pass in array , out md5 zval
smart_str ser_data = {0};
cp_serialize(&ser_data, arr);
zval fun_name, **args[1], *retval, *str;
ZVAL_STRING(&fun_name, "md5", 0);
MAKE_STD_ZVAL(str);
ZVAL_STRINGL(str, ser_data.c, ser_data.len, 1);
args[0] = &str;
if (call_user_function_ex(CG(function_table), NULL, &fun_name, &retval, 1, args, 0, NULL TSRMLS_CC) != SUCCESS)
{
zval_ptr_dtor(&str);
smart_str_free(&ser_data);
return NULL;
}
zval_ptr_dtor(&str);
smart_str_free(&ser_data);
return retval;
}
示例3: php_error
static zval *array2mcpack(zval *data) {
if (Z_TYPE_P(data) != IS_ARRAY) {
php_error(E_WARNING, "parameter type should be array.");
}
zval *mc_pack_v;
MAKE_STD_ZVAL(mc_pack_v);
ZVAL_STRING(mc_pack_v, "PHP_MC_PACK_V2", 0);
zval *params[] = { data, mc_pack_v };
zval *function_name, *retval_ptr;
MAKE_STD_ZVAL(function_name);
ZVAL_STRING(function_name, "mc_pack_array2pack", 0);
MAKE_STD_ZVAL(retval_ptr);
if (call_user_function(CG(function_table), NULL, function_name,
retval_ptr, 1, params TSRMLS_CC) == SUCCESS) {
} else {
php_error(E_WARNING, "call function mc_pack_array2pack fail.");
}
return retval_ptr;
}
示例4: CG_VISIT_FN
CG_VISIT_FN(AST_DECL_VAR, ASTDeclVar) {
// type *node, VisitPhase phase, CGContext *ctx
if (node->type->type_id & TYPE_FLAG_KIND) {
// We don't directly emit meta type expressions
return VISIT_HANDLED;
}
if (ast_node_is_type_definition((ASTBase*)node)) {
// We don't directly emit type definitions
return VISIT_HANDLED;
}
if (phase == VISIT_PRE) {
if (node->is_const) {
CG("const ");
}
}
return VISIT_OK;
}
示例5: zend_implement_iterator
/* {{{ zend_implement_iterator */
static int zend_implement_iterator(zend_class_entry *interface, zend_class_entry *class_type)
{
if (class_type->get_iterator && class_type->get_iterator != zend_user_it_get_iterator) {
if (class_type->type == ZEND_INTERNAL_CLASS) {
/* inheritance ensures the class has the necessary userland methods */
return SUCCESS;
} else {
/* c-level get_iterator cannot be changed */
if (class_type->get_iterator == zend_user_it_get_new_iterator) {
zend_error_noreturn(E_ERROR, "Class %s cannot implement both %s and %s at the same time",
ZSTR_VAL(class_type->name),
ZSTR_VAL(interface->name),
ZSTR_VAL(zend_ce_aggregate->name));
}
return FAILURE;
}
}
class_type->get_iterator = zend_user_it_get_iterator;
if (class_type->iterator_funcs_ptr != NULL) {
class_type->iterator_funcs_ptr->zf_valid = NULL;
class_type->iterator_funcs_ptr->zf_current = NULL;
class_type->iterator_funcs_ptr->zf_key = NULL;
class_type->iterator_funcs_ptr->zf_next = NULL;
class_type->iterator_funcs_ptr->zf_rewind = NULL;
} else if (class_type->type == ZEND_INTERNAL_CLASS) {
class_type->iterator_funcs_ptr = calloc(1, sizeof(zend_class_iterator_funcs));
} else {
class_type->iterator_funcs_ptr = zend_arena_alloc(&CG(arena), sizeof(zend_class_iterator_funcs));
memset(class_type->iterator_funcs_ptr, 0, sizeof(zend_class_iterator_funcs));
}
if (class_type->type == ZEND_INTERNAL_CLASS) {
class_type->iterator_funcs_ptr->zf_rewind = zend_hash_str_find_ptr(&class_type->function_table, "rewind", sizeof("rewind") - 1);
class_type->iterator_funcs_ptr->zf_valid = zend_hash_str_find_ptr(&class_type->function_table, "valid", sizeof("valid") - 1);
class_type->iterator_funcs_ptr->zf_key = zend_hash_str_find_ptr(&class_type->function_table, "key", sizeof("key") - 1);
class_type->iterator_funcs_ptr->zf_current = zend_hash_str_find_ptr(&class_type->function_table, "current", sizeof("current") - 1);
class_type->iterator_funcs_ptr->zf_next = zend_hash_str_find_ptr(&class_type->function_table, "next", sizeof("next") - 1);
}
return SUCCESS;
}
示例6: zend_ast_alloc
ZEND_API zend_ast *zend_ast_create_decl(
zend_ast_kind kind, uint32_t flags, uint32_t start_lineno, zend_string *doc_comment,
zend_string *name, zend_ast *child0, zend_ast *child1, zend_ast *child2, zend_ast *child3
) {
zend_ast_decl *ast;
ast = zend_ast_alloc(sizeof(zend_ast_decl));
ast->kind = kind;
ast->attr = 0;
ast->start_lineno = start_lineno;
ast->end_lineno = CG(zend_lineno);
ast->flags = flags;
ast->lex_pos = LANG_SCNG(yy_text);
ast->doc_comment = doc_comment;
ast->name = name;
ast->child[0] = child0;
ast->child[1] = child1;
ast->child[2] = child2;
ast->child[3] = child3;
return (zend_ast *) ast;
}
示例7: object_common2
static inline int object_common2(UNSERIALIZE_PARAMETER, long elements)
{
zval *retval_ptr = NULL;
zval fname;
if (!process_nested_data(UNSERIALIZE_PASSTHRU, Z_OBJPROP_PP(rval), elements)) {
return 0;
}
if (Z_OBJCE_PP(rval) != PHP_IC_ENTRY &&
zend_hash_exists(&Z_OBJCE_PP(rval)->function_table, "__wakeup", sizeof("__wakeup"))) {
INIT_PZVAL(&fname);
ZVAL_STRINGL(&fname, "__wakeup", sizeof("__wakeup") - 1, 0);
call_user_function_ex(CG(function_table), rval, &fname, &retval_ptr, 0, 0, 1, NULL TSRMLS_CC);
}
if (retval_ptr)
zval_ptr_dtor(&retval_ptr);
return finish_nested_data(UNSERIALIZE_PASSTHRU);
}
示例8: ZEND_METHOD
ZEND_METHOD(Closure, __invoke) /* {{{ */
{
zend_function *func = EX(func);
zval *arguments;
arguments = emalloc(sizeof(zval) * ZEND_NUM_ARGS());
if (zend_get_parameters_array_ex(ZEND_NUM_ARGS(), arguments) == FAILURE) {
efree(arguments);
zend_throw_error(NULL, "Cannot get arguments for calling closure");
RETVAL_FALSE;
} else if (call_user_function_ex(CG(function_table), NULL, getThis(), return_value, ZEND_NUM_ARGS(), arguments, 1, NULL) == FAILURE) {
RETVAL_FALSE;
}
efree(arguments);
/* destruct the function also, then - we have allocated it in get_method */
zend_string_release(func->internal_function.function_name);
efree(func);
#if ZEND_DEBUG
execute_data->func = NULL;
#endif
}
示例9: phalcon_call_static_zval_func_params
/**
* Call single static function on a zval which requires parameters
*/
inline int phalcon_call_static_zval_func_params(zval *return_value, zval *mixed_name, char *method_name, int method_len, zend_uint param_count, zval *params[], int noreturn TSRMLS_DC){
zval *fn;
int status = FAILURE;
if (!noreturn) {
ALLOC_INIT_ZVAL(return_value);
}
ALLOC_INIT_ZVAL(fn);
array_init(fn);
add_next_index_zval(fn, mixed_name);
add_next_index_stringl(fn, method_name, method_len, 1);
status = phalcon_call_user_function(CG(function_table), NULL, fn, return_value, param_count, params TSRMLS_CC);
if (status == FAILURE) {
if(Z_TYPE_P(mixed_name) == IS_STRING) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Call to undefined function %s::%s()", Z_STRVAL_P(mixed_name), method_name);
} else {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Call to undefined function not-callable::%s()", method_name);
}
}
zval_ptr_dtor(&fn);
if (!noreturn) {
zval_ptr_dtor(&return_value);
}
if (EG(exception)) {
status = FAILURE;
}
if (status == FAILURE) {
phalcon_memory_restore_stack(TSRMLS_C);
}
return status;
}
示例10: on_event
void on_event(zend_php_scanner_event event, int token, int line, void *context)
{
zval *token_stream = (zval *) context;
zval keyword;
HashTable *tokens_ht;
zval *token_zv;
switch (event) {
case ON_TOKEN:
if (token == END) break;
if (token >= 256) {
array_init(&keyword);
add_next_index_long(&keyword, token);
add_next_index_stringl(&keyword, (char *)LANG_SCNG(yy_text), LANG_SCNG(yy_leng));
add_next_index_long(&keyword, line);
add_next_index_zval(token_stream, &keyword);
} else {
add_next_index_stringl(token_stream, (char *)LANG_SCNG(yy_text), LANG_SCNG(yy_leng));
}
break;
case ON_FEEDBACK:
tokens_ht = Z_ARRVAL_P(token_stream);
token_zv = zend_hash_index_find(tokens_ht, zend_hash_num_elements(tokens_ht) - 1);
if (token_zv && Z_TYPE_P(token_zv) == IS_ARRAY) {
ZVAL_LONG(zend_hash_index_find(Z_ARRVAL_P(token_zv), 0), token);
}
break;
case ON_STOP:
if (LANG_SCNG(yy_cursor) != LANG_SCNG(yy_limit)) {
array_init(&keyword);
add_next_index_long(&keyword, T_INLINE_HTML);
add_next_index_stringl(&keyword,
(char *)LANG_SCNG(yy_cursor), LANG_SCNG(yy_limit) - LANG_SCNG(yy_cursor));
add_next_index_long(&keyword, CG(zend_lineno));
add_next_index_zval(token_stream, &keyword);
}
break;
}
}
示例11: tokenize_parse
static zend_bool tokenize_parse(zval *return_value, zend_string *source)
{
zval source_zval;
zend_lex_state original_lex_state;
zend_bool original_in_compilation;
zend_bool success;
ZVAL_STR_COPY(&source_zval, source);
original_in_compilation = CG(in_compilation);
CG(in_compilation) = 1;
zend_save_lexical_state(&original_lex_state);
if ((success = (zend_prepare_string_for_scanning(&source_zval, "") == SUCCESS))) {
zval token_stream;
array_init(&token_stream);
CG(ast) = NULL;
CG(ast_arena) = zend_arena_create(1024 * 32);
LANG_SCNG(yy_state) = yycINITIAL;
LANG_SCNG(on_event) = on_event;
LANG_SCNG(on_event_context) = &token_stream;
if((success = (zendparse() == SUCCESS))) {
ZVAL_COPY_VALUE(return_value, &token_stream);
} else {
zval_ptr_dtor(&token_stream);
}
zend_ast_destroy(CG(ast));
zend_arena_destroy(CG(ast_arena));
}
/* restore compiler and scanner global states */
zend_restore_lexical_state(&original_lex_state);
CG(in_compilation) = original_in_compilation;
zval_dtor(&source_zval);
return success;
}
示例12: phalcon_call_func_normal
/**
* This is a function to call PHP functions in a old-style secure way
*/
inline int phalcon_call_func_normal(zval *return_value, char *func_name, int func_length, int noreturn TSRMLS_DC){
zval *fn = NULL;
int status = FAILURE;
zval *local_retval_ptr = NULL;
if (!noreturn) {
ALLOC_INIT_ZVAL(return_value);
}
PHALCON_ALLOC_ZVAL(fn);
ZVAL_STRINGL(fn, func_name, func_length, 1);
status = PHALCON_CALL_USER_FUNCTION(CG(function_table), NULL, fn, return_value, 0, NULL TSRMLS_CC);
if (status == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Call to undefined function %s()", func_name);
}
zval_ptr_dtor(&fn);
if (local_retval_ptr) {
COPY_PZVAL_TO_ZVAL(*return_value, local_retval_ptr);
}
if (!noreturn) {
zval_ptr_dtor(&return_value);
}
if (EG(exception)){
status = FAILURE;
}
if (status == FAILURE) {
phalcon_memory_restore_stack(TSRMLS_C);
}
return status;
}
示例13: ZEND_METHOD
ZEND_METHOD(Closure, __invoke) /* {{{ */
{
zend_function *func = EG(current_execute_data)->function_state.function;
zval ***arguments;
zval *closure_result_ptr = NULL;
arguments = emalloc(sizeof(zval**) * ZEND_NUM_ARGS());
if (zend_get_parameters_array_ex(ZEND_NUM_ARGS(), arguments) == FAILURE) {
efree(arguments);
zend_error(E_RECOVERABLE_ERROR, "Cannot get arguments for calling closure");
RETVAL_FALSE;
} else if (call_user_function_ex(CG(function_table), NULL, this_ptr, &closure_result_ptr, ZEND_NUM_ARGS(), arguments, 1, NULL TSRMLS_CC) == FAILURE) {
RETVAL_FALSE;
} else if (closure_result_ptr) {
zval_ptr_dtor(&return_value);
*return_value_ptr = closure_result_ptr;
}
efree(arguments);
/* destruct the function also, then - we have allocated it in get_method */
efree((char*)func->internal_function.function_name);
efree(func);
}
示例14: zend_exception_get_default
static zend_class_entry *beanstalk_get_exception_base(int root TSRMLS_DC) /* {{{ */
{
#if HAVE_SPL
if (!root) {
if (!spl_ce_RuntimeException) {
zend_class_entry **pce;
if (zend_hash_find(CG(class_table), "runtimeexception",
sizeof("RuntimeException"), (void **) &pce) == SUCCESS) {
spl_ce_RuntimeException = *pce;
return *pce;
}
} else {
return spl_ce_RuntimeException;
}
}
#endif
#if (PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION < 2)
return zend_exception_get_default();
#else
return zend_exception_get_default(TSRMLS_C);
#endif
}
示例15: register_timecop_classes
static int register_timecop_classes()
{
zend_class_entry ce;
zend_class_entry *self_ce, *parent_ce;
parent_ce = zend_hash_str_find_ptr(CG(class_table), "datetime", sizeof("datetime")-1);
if (parent_ce == NULL) {
return SUCCESS; /* DateTime must be initialized before */
}
INIT_CLASS_ENTRY(ce, "TimecopDateTime", timecop_datetime_class_functions);
self_ce = zend_register_internal_class_ex(&ce, parent_ce);
self_ce->create_object = parent_ce->create_object;
TIMECOP_G(ce_DateTime) = parent_ce;
TIMECOP_G(ce_TimecopDateTime) = self_ce;
INIT_CLASS_ENTRY(ce, "TimecopOrigDateTime", timecop_orig_datetime_class_functions);
self_ce = zend_register_internal_class_ex(&ce, parent_ce);
self_ce->create_object = parent_ce->create_object;
return SUCCESS;
}