本文整理汇总了C++中set_input函数的典型用法代码示例。如果您正苦于以下问题:C++ set_input函数的具体用法?C++ set_input怎么用?C++ set_input使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_input函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ignore_last_nick
void ignore_last_nick(char dumb, char *dumber)
{
NickTab *nick;
char *tmp1;
if ((nick = gettabkey(1, NULL))) {
set_input(empty_str);
tmp1 = m_sprintf("%sig %s", get_string_var(CMDCHARS_VAR), nick->nick);
set_input(tmp1);
new_free(&tmp1);
}
update_input(UPDATE_ALL);
}
示例2: for_loop_fix_state_input
void for_loop_fix_state_input(Branch* contents)
{
// This function will look at the state access inside for-loop contents.
// If there's state, the default building functions will have created
// terms that look like this:
//
// input() :state -> unpack_state -> pack_state -> output() :state
//
// We want each loop iteration to have its own state container. So we'll
// insert pack/unpack_state_list_n terms so that each iteration accesses
// state from a list. The result will look like:
//
// input() :state -> unpack_state_list_n(index) -> unpack_state -> pack_state
// -> pack_state_list_n(index) -> output() :state
// First insert the unpack_state_list_n call
Term* stateInput = find_state_input(contents);
// Nothing to do if there's no state input
if (stateInput == NULL)
return;
// Nothing to do if unpack_state_list_n term already exists
if (find_user_with_function(stateInput, FUNCS.unpack_state_list_n) != NULL)
return;
Term* unpackState = find_user_with_function(stateInput, FUNCS.unpack_state);
ca_assert(unpackState != NULL);
Term* index = for_loop_find_index(contents);
Term* unpackStateList = apply(contents, FUNCS.unpack_state_list_n,
TermList(stateInput, index));
transfer_users(stateInput, unpackStateList);
move_before(unpackStateList, unpackState);
set_input(unpackState, 0, unpackStateList);
// Now insert the pack_state_list_n call
Term* stateResult = find_open_state_result(contents, contents->length());
Term* packStateList = apply(contents, FUNCS.pack_state_list_n,
TermList(stateInput, stateResult, index));
packStateList->setBoolProp("final", true);
move_after(packStateList, stateResult);
// Make sure the state output uses this result
Term* stateOutput = append_state_output(contents);
set_input(stateOutput, 0, packStateList);
}
示例3: modify_branch_so_that_state_access_is_indexed
void modify_branch_so_that_state_access_is_indexed(Branch* branch, int index)
{
Term* stateInput = find_state_input(branch);
if (stateInput == NULL)
return;
// If the state output is connected directly to state input, then do nothing.
Term* stateOutput = find_state_output(branch);
if (stateOutput->input(0) == stateInput)
return;
Term* unpackList = apply(branch, FUNCS.unpack_state_from_list, TermList(stateInput));
unpackList->setIntProp("index", index);
move_after_inputs(unpackList);
for (int i=0; i < stateInput->users.length(); i++) {
Term* term = stateInput->users[i];
if (term == unpackList)
continue;
remap_pointers_quick(term, stateInput, unpackList);
}
Term* stateResult = stateOutput->input(0);
ca_assert(stateResult != NULL);
Term* packList = apply(branch, FUNCS.pack_state_to_list,
TermList(stateInput, stateResult));
packList->setIntProp("index", index);
packList->setBoolProp("final", true);
set_input(stateOutput, 0, packList);
move_after(packList, stateResult);
}
示例4: if_block_create_input_placeholders_for_outer_pointers
void if_block_create_input_placeholders_for_outer_pointers(Term* ifCall)
{
Branch* contents = nested_contents(ifCall);
TermList outerTerms;
// Find outer pointers across each case
for (CaseIterator it(contents); it.unfinished(); it.advance()) {
list_outer_pointers(nested_contents(it.current()), &outerTerms);
}
ca_assert(ifCall->numInputs() == 0);
// Create input placeholders and add inputs for all outer pointers
for (int i=0; i < outerTerms.length(); i++) {
Term* outer = outerTerms[i];
set_input(ifCall, i, outer);
Term* placeholder = append_input_placeholder(nested_contents(ifCall));
rename(placeholder, outer->name);
// Go through each case and repoint to this new placeholder
for (CaseIterator it(contents); it.unfinished(); it.advance()) {
remap_pointers_quick(nested_contents(it.current()), outer, placeholder);
}
}
}
示例5: tun_start
static ErlDrvData tun_start(ErlDrvPort port, char *args)
{
struct tun_state *state;
int fd;
int mode;
char dev_name[IFNAMSIZ];
state = (struct tun_state*) sys_alloc(sizeof(struct tun_state));
if (state == NULL) {
errno = ENOMEM; /* appropriate to set errno? */
return ERL_DRV_ERROR_ERRNO;
}
if (!parse_args(args, &mode, state->dev, IFNAMSIZ - 1)) {
return ERL_DRV_ERROR_BADARG;
}
fd = make_if(mode, state->dev);
if (fd < 0) {
return ERL_DRV_ERROR_GENERAL;
}
state->port = port;
state->fd = fd;
state->active = ACTIVE_FALSE;
set_input(state, 0);
return (ErlDrvData)state;
}
示例6: tun_stop
static void tun_stop(ErlDrvData data)
{
struct tun_state *state = (struct tun_state *)data;
set_input(state, 0);
close(state->fd);
sys_free(state);
}
示例7: compile_file
/* Compile an entire file of output from cpp, named NAME.
Write a file of assembly output and various debugging dumps. */
static void compile_file(char *name)
{
FILE *ifile;
#if !USE_CPPLIB
/* Open input file. */
if (name == 0 || !strcmp (name, "-"))
{
ifile = stdin;
name = "stdin";
}
else
ifile = fopen (name, "r");
if (ifile == 0)
pfatal_with_name (name);
#ifdef IO_BUFFER_SIZE
setvbuf(ifile, (char *) xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE);
#endif
#endif /* !USE_CPPLIB */
set_nomem_handler(outofmemory);
set_input(ifile, name);
init_lex(); /* needs to go before init_semantics, since inits
dummy_location */
init_semantics();
if (yyparse () != 0)
{
if (errorcount == 0)
fprintf (stderr, "Errors detected in input file (your bison.simple is out of date)");
}
fclose (ifile);
if (errorcount == 0)
{
/*if (flag_parse_only)
{
fprintf(stderr, "\nDONE. Unparsing............\n\n");
unparse(stdout, the_program);
}
else
exit(exec_cc1(the_program));*/
if (the_program)
{
parsed_file pf;
pf = ralloc(parse_region, struct parsed_file);
pf->name = name;
pf->program = the_program;
dd_add_last(parse_region, parsed_files, pf);
analyze(the_program);
}
}
}
示例8: set_input
bool hts_engine_call::execute()
{
set_input();
set_output();
engine_impl->synthesize();
return !output.is_stopped();
}
示例9: insert_looped_placeholders
void insert_looped_placeholders(Block* contents)
{
Value names;
list_names_that_must_be_looped(contents, &names);
for (ListIterator it(&names); it; ++it) {
Term* inputPlaceholder = append_input_placeholder(contents);
Value* name = it.value();
rename(inputPlaceholder, name);
Value owningTermVal;
owningTermVal.set_term(contents->owningTerm);
Term* outsideTerm = find_name_at(&owningTermVal, name);
Term* innerResult = find_local_name(contents, name);
Term* outputPlaceholder = append_output_placeholder(contents, innerResult);
rename(outputPlaceholder, name);
set_inputs(inputPlaceholder, TermList(outsideTerm, outputPlaceholder));
for (BlockInputIterator it(contents); it; ++it) {
Term* term = it.currentTerm();
if (it.currentInput() == outsideTerm && term != inputPlaceholder)
set_input(term, it.currentInputIndex(), inputPlaceholder);
}
}
}
示例10: nick_completion
void nick_completion(char dumb, char *dumber)
{
char *q, *line;
int i = -1;
char *nick = NULL, *tmp;
q = line = m_strdup(¤t_screen->input_buffer[MIN_POS]);
if (in_completion == STATE_NORMAL) {
i = word_count(line);
nick = extract_words(line, i - 1, i);
}
if (nick)
line[strlen(line) - strlen(nick)] = 0;
else
*line = 0;
if ((tmp = getchannick(input_lastmsg, nick && *nick ? nick : NULL))) {
malloc_strcat(&q, tmp);
set_input(q);
update_input(UPDATE_ALL);
malloc_strcpy(&input_lastmsg, tmp);
in_completion = STATE_COMPLETE;
}
new_free(&q);
new_free(&nick);
}
示例11: set_input
void CNeuralNetworkTest::process(u32 learn)
{
u32 j;
set_input();
set_required_output();
neural_network->process(input);
if (learn != 0)
neural_network->learn(required_output);
for (j = 0; j < output.size(); j++)
output[j] = neural_network->get()[j];
error_now = 0.0;
for (j = 0; j < output.size(); j++)
{
float tmp = (required_output[j] - output[j]);
if (tmp < 0.0)
tmp = -tmp;
error_now+= tmp;
}
float k = 0.98;
error_filtered = k*error_filtered + (1.0 - k)*error_now;
error_total+= error_now;
}
示例12: repoint_terms_to_use_input_placeholders
void repoint_terms_to_use_input_placeholders(Branch* contents)
{
// Visit every term
for (int i=0; i < contents->length(); i++) {
Term* term = contents->get(i);
// Visit every input
for (int inputIndex=0; inputIndex < term->numInputs(); inputIndex++) {
Term* input = term->input(inputIndex);
if (input == NULL)
continue;
// If the input is outside this branch, then see if we have a named
// input that could be used instead.
if (input->owningBranch == contents || input->name == "")
continue;
Term* replacement = find_input_placeholder_with_name(contents, input->name.c_str());
if (replacement == NULL)
continue;
set_input(term, inputIndex, replacement);
}
}
}
示例13: Token
Token :: Token(char input, Category category, double actual_value, int precedence)
{
set_input(input);
set_category(category);
set_actual_value(actual_value);
set_precedence(precedence);
}
示例14: main
// Main entry to the interpret. No tests will be launched, only
// pure interpret will be compiled
int main(int argc, char *argv[]) {
int result;
if ((result = check_params(argc, argv))) {
return result;
}
// naalokujeme sdilenou datovou strukturu
make_data_structure();
// otevrem soubor
set_input(argv[1]);
#ifdef LEX_TEST
do {
get_token();
} while (d->token->type != EOF);
#else
// parse
parser_prepare(d);
d = parser_run();
if (d->error != CODE_OK) {
return 2;
}
InterpretInit(d->tree->d.list);
// interpret the list
InterpretRun();
#endif
return 0;
}
示例15: change_function
void
Term::setDependency(int index, Term* term)
{
if (index == 0)
change_function(this, term);
else
set_input(this, index - 1, term);
}