这篇教程C++ CG函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中CG函数的典型用法代码示例。如果您正苦于以下问题:C++ CG函数的具体用法?C++ CG怎么用?C++ CG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了CG函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: cpGetConfigzval * 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;}
开发者ID:damaainan,项目名称:php-cp,代码行数:21,
示例2: cpMD5CPINLINE 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;}
开发者ID:damaainan,项目名称:php-cp,代码行数:21,
示例3: php_errorstatic 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;}
开发者ID:Raaaay,项目名称:mcphessian,代码行数:21,
示例4: CG_VISIT_FNCG_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;}
开发者ID:breckinloggins,项目名称:lmac,代码行数:21,
示例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;}
开发者ID:auroraeosrose,项目名称:php-src,代码行数:40,
示例6: zend_ast_allocZEND_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;}
开发者ID:13572293130,项目名称:php-src,代码行数:22,
示例7: object_common2static 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);}
开发者ID:vpj,项目名称:PHP-Extension-API,代码行数:22,
示例8: ZEND_METHODZEND_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}
开发者ID:Jyhwenchai,项目名称:Share,代码行数:22,
示例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;}
开发者ID:Tigerlee1987,项目名称:cphalcon,代码行数:42,
示例10: on_eventvoid 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; }}
开发者ID:Synchro,项目名称:php-src,代码行数:39,
示例11: tokenize_parsestatic 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;}
开发者ID:Synchro,项目名称:php-src,代码行数:41,
示例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;}
开发者ID:gplanchat,项目名称:cphalcon,代码行数:41,
示例13: ZEND_METHODZEND_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);}
开发者ID:nishisan,项目名称:scripts,代码行数:23,
示例14: zend_exception_get_defaultstatic 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}
开发者ID:amumu,项目名称:php-beanstalk-old,代码行数:23,
示例15: register_timecop_classesstatic 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;}
开发者ID:dreamsxin,项目名称:php-timecop,代码行数:23,
示例16: mlfi_abort/* {{{ mlfi_abort()*/static sfsistat mlfi_abort(SMFICTX *ctx){ zval function_name, retval; int status; /* call userland */ INIT_ZVAL(function_name); ZVAL_STRING(&function_name, "milter_abort", 0); /* set the milter context for possible use in API functions */ MG(ctx) = ctx; MG(state) = MLFI_ABORT; status = call_user_function(CG(function_table), NULL, &function_name, &retval, 0, NULL); MG(state) = MLFI_NONE; if (status == SUCCESS && Z_TYPE(retval) == IS_LONG) { return Z_LVAL(retval); } return SMFIS_CONTINUE;}
开发者ID:AmesianX,项目名称:php-src,代码行数:25,
示例17: phalcon_call_func/** * Call single function which not requires parameters */int phalcon_call_func(zval *return_value, char *func_name, int func_length, int noreturn, int fcache_pointer 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_cache_lookup_function(fn, fcache_pointer); if (status == FAILURE) { return FAILURE; }*/ status = call_user_function(CG(function_table), NULL, fn, return_value, 0, NULL TSRMLS_CC); //status = phalcon_call_user_function_ex(CG(function_table), NULL, fn, &local_retval_ptr, 0, NULL, 1, NULL, phalcon_fcall_cache[fcache_pointer] TSRMLS_CC); if (status == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Call to undefined function %s()", func_name); return FAILURE; } zval_ptr_dtor(&fn); if (local_retval_ptr) { COPY_PZVAL_TO_ZVAL(*return_value, local_retval_ptr); } if (!noreturn) { zval_ptr_dtor(&return_value); } return status;}
开发者ID:xingskycn,项目名称:cphalcon,代码行数:40,
示例18: mlfi_envrcpt/* {{{ mlfi_envrcpt()*/static sfsistat mlfi_envrcpt(SMFICTX *ctx, char **argv){ zval function_name, retval, *param[1]; int status; TSRMLS_FETCH(); /* call userland */ INIT_ZVAL(function_name); ALLOC_ZVAL(param[0]); INIT_PZVAL(param[0]); ZVAL_STRING(&function_name, "milter_envrcpt", 0); array_init(param[0]); while (*argv) { add_next_index_string(param[0], *argv, 1); argv++; } /* set the milter context for possible use in API functions */ MG(ctx) = ctx; MG(state) = MLFI_ENVRCPT; status = call_user_function(CG(function_table), NULL, &function_name, &retval, 1, param TSRMLS_CC); MG(state) = MLFI_NONE; zval_ptr_dtor(param); if (status == SUCCESS && Z_TYPE(retval) == IS_LONG) { return Z_LVAL(retval); } return SMFIS_CONTINUE;}
开发者ID:do-aki,项目名称:petipeti,代码行数:38,
示例19: phalcon_call_static_func_zval_params/** * Call single function on zval which requires parameters */int phalcon_call_static_func_zval_params(zval *return_value, zval *mixed_name, char *method_name, zend_uint param_count, zval *params[], int noreturn TSRMLS_DC){ int status = FAILURE; if (!noreturn) { ALLOC_INIT_ZVAL(return_value); } status = call_user_function(CG(function_table), NULL, mixed_name, 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 %s()", method_name); } return FAILURE; } if (!noreturn) { zval_ptr_dtor(&return_value); } return status;}
开发者ID:xingskycn,项目名称:cphalcon,代码行数:27,
示例20: main//.........这里部分代码省略......... } break; }#ifndef PHP_CLI_WIN32_NO_CONSOLE case 'S': sapi_module = &cli_server_sapi_module; cli_server_sapi_module.additional_functions = server_additional_functions; break;#endif case 'h': /* help & quit */ case '?': php_cli_usage(argv[0]); goto out; case 'i': case 'v': case 'm': sapi_module = &cli_sapi_module; goto exit_loop; case 'e': /* enable extended info output */ use_extended_info = 1; break; } }exit_loop: sapi_module->ini_defaults = sapi_cli_ini_defaults; sapi_module->php_ini_path_override = ini_path_override; sapi_module->phpinfo_as_text = 1; sapi_module->php_ini_ignore_cwd = 1; sapi_startup(sapi_module); sapi_started = 1; sapi_module->php_ini_ignore = ini_ignore; sapi_module->executable_location = argv[0]; if (sapi_module == &cli_sapi_module) { if (ini_entries) { ini_entries = realloc(ini_entries, ini_entries_len + sizeof(HARDCODED_INI)); memmove(ini_entries + sizeof(HARDCODED_INI) - 2, ini_entries, ini_entries_len + 1); memcpy(ini_entries, HARDCODED_INI, sizeof(HARDCODED_INI) - 2); } else { ini_entries = malloc(sizeof(HARDCODED_INI)); memcpy(ini_entries, HARDCODED_INI, sizeof(HARDCODED_INI)); } ini_entries_len += sizeof(HARDCODED_INI) - 2; } sapi_module->ini_entries = ini_entries; /* startup after we get the above ini override se we get things right */ if (sapi_module->startup(sapi_module) == FAILURE) { /* there is no way to see if we must call zend_ini_deactivate() * since we cannot check if EG(ini_directives) has been initialised * because the executor's constructor does not set initialize it. * Apart from that there seems no need for zend_ini_deactivate() yet. * So we goto out_err.*/ exit_status = 1; goto out; } module_started = 1; /* -e option */ if (use_extended_info) { CG(compiler_options) |= ZEND_COMPILE_EXTENDED_INFO; } zend_first_try {#ifndef PHP_CLI_WIN32_NO_CONSOLE if (sapi_module == &cli_sapi_module) {#endif exit_status = do_cli(argc, argv);#ifndef PHP_CLI_WIN32_NO_CONSOLE } else { exit_status = do_cli_server(argc, argv); }#endif } zend_end_try();out: if (ini_path_override) { free(ini_path_override); } if (ini_entries) { free(ini_entries); } if (module_started) { php_module_shutdown(); } if (sapi_started) { sapi_shutdown(); }#ifdef ZTS tsrm_shutdown();#endif /* * Do not move this de-initialization. It needs to happen right before * exiting. */ cleanup_ps_args(argv); exit(exit_status);}
开发者ID:EleTeam,项目名称:php-src,代码行数:101,
示例21: zend_arena_allocstatic inline void *zend_ast_alloc(size_t size) { return zend_arena_alloc(&CG(ast_arena), size);}
开发者ID:13572293130,项目名称:php-src,代码行数:3,
示例22: zend_generator_closeZEND_API void zend_generator_close(zend_generator *generator, zend_bool finished_execution TSRMLS_DC) /* {{{ */{ if (generator->value) { zval_ptr_dtor(&generator->value); generator->value = NULL; } if (generator->key) { zval_ptr_dtor(&generator->key); generator->key = NULL; } if (generator->execute_data) { zend_execute_data *execute_data = generator->execute_data; zend_op_array *op_array = execute_data->op_array; if (!execute_data->symbol_table) { zend_free_compiled_variables(execute_data); } else { zend_clean_and_cache_symbol_table(execute_data->symbol_table TSRMLS_CC); } if (execute_data->current_this) { zval_ptr_dtor(&execute_data->current_this); } /* A fatal error / die occured during the generator execution. Trying to clean * up the stack may not be safe in this case. */ if (CG(unclean_shutdown)) { return; } /* If the generator is closed before it can finish execution (reach * a return statement) we have to free loop variables manually, as * we don't know whether the SWITCH_FREE / FREE opcodes have run */ if (!finished_execution) { /* -1 required because we want the last run opcode, not the * next to-be-run one. */ zend_uint op_num = execute_data->opline - op_array->opcodes - 1; int i; for (i = 0; i < op_array->last_brk_cont; ++i) { zend_brk_cont_element *brk_cont = op_array->brk_cont_array + i; if (brk_cont->start < 0) { continue; } else if (brk_cont->start > op_num) { break; } else if (brk_cont->brk > op_num) { zend_op *brk_opline = op_array->opcodes + brk_cont->brk; switch (brk_opline->opcode) { case ZEND_SWITCH_FREE: { temp_variable *var = EX_TMP_VAR(execute_data, brk_opline->op1.var); zval_ptr_dtor(&var->var.ptr); } break; case ZEND_FREE: { temp_variable *var = EX_TMP_VAR(execute_data, brk_opline->op1.var); zval_dtor(&var->tmp_var); } break; } } } } /* Clear any backed up stack arguments */ if (generator->stack != EG(argument_stack)) { void **ptr = generator->stack->top - 1; void **end = zend_vm_stack_frame_base(execute_data); /* If the top stack element is the argument count, skip it */ if (execute_data->function_state.arguments) { ptr--; } for (; ptr >= end; --ptr) { zval_ptr_dtor((zval**) ptr); } } while (execute_data->call >= execute_data->call_slots) { if (execute_data->call->object) { zval_ptr_dtor(&execute_data->call->object); } execute_data->call--; } /* We have added an additional stack frame in prev_execute_data, so we * have to free it. It also contains the arguments passed to the * generator (for func_get_args) so those have to be freed too. */ { zend_execute_data *prev_execute_data = execute_data->prev_execute_data; void **arguments = prev_execute_data->function_state.arguments; if (arguments) { int arguments_count = (int) (zend_uintptr_t) *arguments;//.........这里部分代码省略.........
开发者ID:RozeDoyanawa,项目名称:php-src,代码行数:101,
示例23: GetGradient/////////////////////////////////////////////////////////////////////////////// Newton-Raphson's method/////////////////////////////////////////////////////////////////////////////void CDiffFunction::Newton(std::vector<double> &vMax, bool fTrace){ const std::vector<double> &vG = GetGradient(); const std::vector<double> &vH = GetHessian(); int n = GetDimensions(); if (fTrace) std::cout << '/n'; for (int Iterations = MaxNewtonIterations; --Iterations >= 0;) { double L = GetOutput(&vMax[0]); ComputeGradient(); ComputeHessian(); if (fTrace) { std::cout << std::setw(5) << Iterations; std::cout << std::setw(12) << vMax[0]; std::cout << std::setw(12) << L; std::cout << std::setw(12) << vG[0]; std::cout << std::setw(12) << vH[0]; std::cout << '/n'; } // // Compute Gradient multiplied by inverse of opposite of Hessian // vStep = vG; if (CMatrixOperations::Cholesky(&vH[0], &vCholesky[0], n)) CMatrixOperations::Solve(&vCholesky[0], &vStep[0], n); // // If the Hessian is not definite negative, CG // else { CG(&vMax[0], fTrace); return; } // // Apply change // for (int i = n; --i >= 0;) vxTemp[i] = Normalize(vMax[i] + vStep[i]); // // If probability did not improve, use CG // double LNew = GetOutput(&vxTemp[0]); double NewtonStep = 1.0; if ((LNew != LNew || LNew < L) && NewtonStep > MinNewtonStep) { CG(&vMax[0], fTrace); return; } // // Stop looping if small improvement // vMax = vxTemp; if (LNew - L < NewtonThreshold) return; } //std::cerr << "warning: reached MaxNewtonIterations/n";}
开发者ID:jdc2172,项目名称:clop,代码行数:72,
示例24: zend_file_cache_get_bin_file_pathzend_persistent_script *zend_file_cache_script_load(zend_file_handle *file_handle){ zend_string *full_path = file_handle->opened_path; int fd; char *filename; zend_persistent_script *script; zend_file_cache_metainfo info; zend_accel_hash_entry *bucket; void *mem, *checkpoint, *buf; int cache_it = 1; if (!full_path) { return NULL; } filename = zend_file_cache_get_bin_file_path(full_path); fd = open(filename, O_RDONLY | O_BINARY); if (fd < 0) { efree(filename); return NULL; } if (zend_file_cache_flock(fd, LOCK_SH) != 0) { close(fd); efree(filename); return NULL; } if (read(fd, &info, sizeof(info)) != sizeof(info)) { zend_accel_error(ACCEL_LOG_WARNING, "opcache cannot read from file '%s'/n", filename); zend_file_cache_flock(fd, LOCK_UN); close(fd); unlink(filename); efree(filename); return NULL; } /* verify header */ if (memcmp(info.magic, "OPCACHE", 8) != 0) { zend_accel_error(ACCEL_LOG_WARNING, "opcache cannot read from file '%s' (wrong header)/n", filename); zend_file_cache_flock(fd, LOCK_UN); close(fd); unlink(filename); efree(filename); return NULL; } if (memcmp(info.system_id, ZCG(system_id), 32) != 0) { zend_accel_error(ACCEL_LOG_WARNING, "opcache cannot read from file '%s' (wrong /"system_id/")/n", filename); zend_file_cache_flock(fd, LOCK_UN); close(fd); unlink(filename); efree(filename); return NULL; } /* verify timestamp */ if (ZCG(accel_directives).validate_timestamps && zend_get_file_handle_timestamp(file_handle, NULL) != info.timestamp) { if (zend_file_cache_flock(fd, LOCK_UN) != 0) { zend_accel_error(ACCEL_LOG_WARNING, "opcache cannot unlock file '%s'/n", filename); } close(fd); unlink(filename); efree(filename); return NULL; } checkpoint = zend_arena_checkpoint(CG(arena));#ifdef __SSE2__ /* Align to 64-byte boundary */ mem = zend_arena_alloc(&CG(arena), info.mem_size + info.str_size + 64); mem = (void*)(((zend_uintptr_t)mem + 63L) & ~63L);#else mem = zend_arena_alloc(&CG(arena), info.mem_size + info.str_size);#endif if (read(fd, mem, info.mem_size + info.str_size) != (ssize_t)(info.mem_size + info.str_size)) { zend_accel_error(ACCEL_LOG_WARNING, "opcache cannot read from file '%s'/n", filename); zend_file_cache_flock(fd, LOCK_UN); close(fd); unlink(filename); zend_arena_release(&CG(arena), checkpoint); efree(filename); return NULL; } if (zend_file_cache_flock(fd, LOCK_UN) != 0) { zend_accel_error(ACCEL_LOG_WARNING, "opcache cannot unlock file '%s'/n", filename); } close(fd); /* verify checksum */ if (ZCG(accel_directives).file_cache_consistency_checks && zend_adler32(ADLER32_INIT, mem, info.mem_size + info.str_size) != info.checksum) { zend_accel_error(ACCEL_LOG_WARNING, "corrupted file '%s'/n", filename); unlink(filename); zend_arena_release(&CG(arena), checkpoint); efree(filename); return NULL; }//.........这里部分代码省略.........
开发者ID:8liang,项目名称:php-src,代码行数:101,
示例25: php_var_unserialize_ex//.........这里部分代码省略......... break; } /* Try to find class directly */ BG(serialize_lock)++; ce = zend_lookup_class(class_name); if (ce) { BG(serialize_lock)--; if (EG(exception)) { zend_string_release(class_name); return 0; } break; } BG(serialize_lock)--; if (EG(exception)) { zend_string_release(class_name); return 0; } /* Check for unserialize callback */ if ((PG(unserialize_callback_func) == NULL) || (PG(unserialize_callback_func)[0] == '/0')) { incomplete_class = 1; ce = PHP_IC_ENTRY; break; } /* Call unserialize callback */ ZVAL_STRING(&user_func, PG(unserialize_callback_func)); ZVAL_STR_COPY(&args[0], class_name); BG(serialize_lock)++; if (call_user_function_ex(CG(function_table), NULL, &user_func, &retval, 1, args, 0, NULL) != SUCCESS) { BG(serialize_lock)--; if (EG(exception)) { zend_string_release(class_name); zval_ptr_dtor(&user_func); zval_ptr_dtor(&args[0]); return 0; } php_error_docref(NULL, E_WARNING, "defined (%s) but not found", Z_STRVAL(user_func)); incomplete_class = 1; ce = PHP_IC_ENTRY; zval_ptr_dtor(&user_func); zval_ptr_dtor(&args[0]); break; } BG(serialize_lock)--; zval_ptr_dtor(&retval); if (EG(exception)) { zend_string_release(class_name); zval_ptr_dtor(&user_func); zval_ptr_dtor(&args[0]); return 0; } /* The callback function may have defined the class */ if ((ce = zend_lookup_class(class_name)) == NULL) { php_error_docref(NULL, E_WARNING, "Function %s() hasn't defined the class it was called for", Z_STRVAL(user_func)); incomplete_class = 1; ce = PHP_IC_ENTRY; } zval_ptr_dtor(&user_func); zval_ptr_dtor(&args[0]);
开发者ID:Freeaqingme,项目名称:php-src,代码行数:67,
示例26: zend_set_default_compile_time_valuesstatic void zend_set_default_compile_time_values(void) /* {{{ */{ /* default compile-time values */ CG(short_tags) = short_tags_default; CG(compiler_options) = compiler_options_default;}
开发者ID:LuthandoE,项目名称:php-src,代码行数:6,
示例27: apc_copy_internal_stringsstatic void apc_copy_internal_strings(TSRMLS_D){ Bucket *p, *q; p = CG(function_table)->pListHead; while (p) { if (p->nKeyLength) { p->arKey = apc_new_interned_string(p->arKey, p->nKeyLength TSRMLS_CC); } p = p->pListNext; } p = CG(class_table)->pListHead; while (p) { zend_class_entry *ce = (zend_class_entry*)(p->pDataPtr); if (p->nKeyLength) { p->arKey = apc_new_interned_string(p->arKey, p->nKeyLength TSRMLS_CC); } if (ce->name) { ce->name = apc_new_interned_string(ce->name, ce->name_length+1 TSRMLS_CC); } q = ce->properties_info.pListHead; while (q) { zend_property_info *info = (zend_property_info*)(q->pData); if (q->nKeyLength) { q->arKey = apc_new_interned_string(q->arKey, q->nKeyLength TSRMLS_CC); } if (info->name) { info->name = apc_new_interned_string(info->name, info->name_length+1 TSRMLS_CC); } q = q->pListNext; } q = ce->function_table.pListHead; while (q) { if (q->nKeyLength) { q->arKey = apc_new_interned_string(q->arKey, q->nKeyLength TSRMLS_CC); } q = q->pListNext; } q = ce->constants_table.pListHead; while (q) { if (q->nKeyLength) { q->arKey = apc_new_interned_string(q->arKey, q->nKeyLength TSRMLS_CC); } q = q->pListNext; } p = p->pListNext; } p = EG(zend_constants)->pListHead; while (p) { if (p->nKeyLength) { p->arKey = apc_new_interned_string(p->arKey, p->nKeyLength TSRMLS_CC); } p = p->pListNext; }}
开发者ID:Brave-Cheng,项目名称:history-codes,代码行数:66,
示例28: zend_create_closureZEND_API void zend_create_closure(zval *res, zend_function *func, zend_class_entry *scope, zend_class_entry *called_scope, zval *this_ptr) /* {{{ */{ zend_closure *closure; object_init_ex(res, zend_ce_closure); closure = (zend_closure *)Z_OBJ_P(res); if ((scope == NULL) && this_ptr && (Z_TYPE_P(this_ptr) != IS_UNDEF)) { /* use dummy scope if we're binding an object without specifying a scope */ /* maybe it would be better to create one for this purpose */ scope = zend_ce_closure; } if (func->type == ZEND_USER_FUNCTION) { memcpy(&closure->func, func, sizeof(zend_op_array)); closure->func.common.fn_flags |= ZEND_ACC_CLOSURE; if (closure->func.op_array.static_variables) { closure->func.op_array.static_variables = zend_array_dup(closure->func.op_array.static_variables); } /* Runtime cache is scope-dependent, so we cannot reuse it if the scope changed */ if (!closure->func.op_array.run_time_cache || func->common.scope != scope || (func->common.fn_flags & ZEND_ACC_NO_RT_ARENA) ) { if (!func->op_array.run_time_cache && (func->common.fn_flags & ZEND_ACC_CLOSURE)) { /* If a real closure is used for the first time, we create a shared runtime cache * and remember which scope it is for. */ func->common.scope = scope; func->op_array.run_time_cache = zend_arena_alloc(&CG(arena), func->op_array.cache_size); closure->func.op_array.run_time_cache = func->op_array.run_time_cache; } else { /* Otherwise, we use a non-shared runtime cache */ closure->func.op_array.run_time_cache = emalloc(func->op_array.cache_size); closure->func.op_array.fn_flags |= ZEND_ACC_NO_RT_ARENA; } memset(closure->func.op_array.run_time_cache, 0, func->op_array.cache_size); } if (closure->func.op_array.refcount) { (*closure->func.op_array.refcount)++; } } else { memcpy(&closure->func, func, sizeof(zend_internal_function)); closure->func.common.fn_flags |= ZEND_ACC_CLOSURE; /* wrap internal function handler to avoid memory leak */ if (UNEXPECTED(closure->func.internal_function.handler == zend_closure_internal_handler)) { /* avoid infinity recursion, by taking handler from nested closure */ zend_closure *nested = (zend_closure*)((char*)func - XtOffsetOf(zend_closure, func)); ZEND_ASSERT(nested->std.ce == zend_ce_closure); closure->orig_internal_handler = nested->orig_internal_handler; } else { closure->orig_internal_handler = closure->func.internal_function.handler; } closure->func.internal_function.handler = zend_closure_internal_handler; if (!func->common.scope) { /* if it's a free function, we won't set scope & this since they're meaningless */ this_ptr = NULL; scope = NULL; } } ZVAL_UNDEF(&closure->this_ptr); /* Invariant: * If the closure is unscoped or static, it has no bound object. */ closure->func.common.scope = scope; closure->called_scope = called_scope; if (scope) { closure->func.common.fn_flags |= ZEND_ACC_PUBLIC; if (this_ptr && Z_TYPE_P(this_ptr) == IS_OBJECT && (closure->func.common.fn_flags & ZEND_ACC_STATIC) == 0) { ZVAL_COPY(&closure->this_ptr, this_ptr); } }}
开发者ID:Mingyangzu,项目名称:php-src,代码行数:75,
示例29: do_clistatic int do_cli(int argc, char **argv) /* {{{ */{ int c; zend_file_handle file_handle; int behavior = PHP_MODE_STANDARD; char *reflection_what = NULL; volatile int request_started = 0; volatile int exit_status = 0; char *php_optarg = NULL, *orig_optarg = NULL; int php_optind = 1, orig_optind = 1; char *exec_direct=NULL, *exec_run=NULL, *exec_begin=NULL, *exec_end=NULL; char *arg_free=NULL, **arg_excp=&arg_free; char *script_file=NULL, *translated_path = NULL; int interactive=0; int lineno = 0; const char *param_error=NULL; int hide_argv = 0; zend_try { CG(in_compilation) = 0; /* not initialized but needed for several options */ while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0, 2)) != -1) { switch (c) { case 'i': /* php info & quit */ if (php_request_startup()==FAILURE) { goto err; } request_started = 1; php_print_info(0xFFFFFFFF); php_output_end_all(); exit_status = (c == '?' && argc > 1 && !strchr(argv[1], c)); goto out; case 'v': /* show php version & quit */ php_printf("PHP %s (%s) (built: %s %s) ( %s)/nCopyright (c) 1997-2016 The PHP Group/n%s", PHP_VERSION, cli_sapi_module.name, __DATE__, __TIME__,#if ZTS "ZTS "#else "NTS "#endif#if ZEND_DEBUG "DEBUG "#endif#ifdef HAVE_GCOV "GCOV "#endif , get_zend_version() ); sapi_deactivate(); goto out; case 'm': /* list compiled in modules */ if (php_request_startup()==FAILURE) { goto err; } request_started = 1; php_printf("[PHP Modules]/n"); print_modules(); php_printf("/n[Zend Modules]/n"); print_extensions(); php_printf("/n"); php_output_end_all(); exit_status=0; goto out; default: break; } } /* Set some CLI defaults */ SG(options) |= SAPI_OPTION_NO_CHDIR; php_optind = orig_optind; php_optarg = orig_optarg; while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0, 2)) != -1) { switch (c) { case 'a': /* interactive mode */ if (!interactive) { if (behavior != PHP_MODE_STANDARD) { param_error = param_mode_conflict; break; } interactive=1; } break; case 'C': /* don't chdir to the script directory */ /* This is default so NOP */ break; case 'F': if (behavior == PHP_MODE_PROCESS_STDIN) { if (exec_run || script_file) {//.........这里部分代码省略.........
开发者ID:EleTeam,项目名称:php-src,代码行数:101,
注:本文中的CG函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ CGAL_assertion函数代码示例 C++ CFormat函数代码示例 |