void ksf_test() { testFuncObj *r = new testFuncObj("r"); testFuncObj *g = new testFuncObj("g"); testFuncObj *f = new testFuncObj("f"); testFuncObj *h = new testFuncObj("h"); testFuncObj *b = new testFuncObj("b"); testFuncObj *x = new testFuncObj("x"); testFuncObj *a = new testFuncObj("a"); k_value = 2; call2(r,1); call2(g,2); call2(f,3); ret(); call2(h,6); call2(f,5); call2(b,7); ret(); ret(); ret(); ret(); call2(a,4); call2(h,3); call2(x,8); cout << "dump of ksf\n"; dump(ctx.kSlabForest); }
int main() { auto callPtr = Wrapper<AbstractPayOff>( new PayOffCall(50)); PayOffPut put(50); auto putPtr = Wrapper<AbstractPayOff>(put); PayOffCall call2(50); std::cout << (*callPtr)(55) << std::endl; // 5 std::cout << (*putPtr)(43) << std::endl; // 7 std::cout << std::endl; // Look at ptr addressing // These should all be on the stack next to each other std::cout << &callPtr << std::endl; std::cout << &put << std::endl; std::cout << &putPtr << std::endl; std::cout << &call2 << std::endl; std::cout << std::endl; std::cout << &(*callPtr) << std::endl; std::cout << &(*putPtr) << std::endl; return 0; }
/* // === FUNCTION ====================================================================== // Name: main // Description: // ===================================================================================== */ int main(int argc, char *argv[]) { { // bind可以绑定所有参数,也可以绑定部分参数 auto fun = std::bind(output_odd, std::placeholders::_1); for (int i=0; i<10; ++i) { call(i, fun); } std::cout << std::endl; } { auto fun = std::bind(output_even, std::placeholders::_1); for (int i=0; i<10; ++i) { call(i, fun); } std::cout << std::endl; } { output_reverse(1, 2); auto fun = std::bind(output_reverse, std::placeholders::_2, std::placeholders::_1); call2(1, 2, fun); } return EXIT_SUCCESS; } // ---------- end of function main ----------
int main(int argc, char *argv[]) { call0(); call1(); call2(0,0,0,0,0,0,0,0,0); call3(); call4(); }
void lock_file (Lisp_Object fn) { register Lisp_Object attack, orig_fn, encoded_fn; register char *lfname, *locker; lock_info_type lock_info; struct gcpro gcpro1; /* Don't do locking while dumping Emacs. Uncompressing wtmp files uses call-process, which does not work in an uninitialized Emacs. */ if (! NILP (Vpurify_flag)) return; orig_fn = fn; GCPRO1 (fn); fn = Fexpand_file_name (fn, Qnil); encoded_fn = ENCODE_FILE (fn); /* Create the name of the lock-file for file fn */ MAKE_LOCK_NAME (lfname, encoded_fn); /* See if this file is visited and has changed on disk since it was visited. */ { register Lisp_Object subject_buf; subject_buf = get_truename_buffer (orig_fn); if (!NILP (subject_buf) && NILP (Fverify_visited_file_modtime (subject_buf)) && !NILP (Ffile_exists_p (fn))) call1 (intern ("ask-user-about-supersession-threat"), fn); } UNGCPRO; /* Try to lock the lock. */ if (lock_if_free (&lock_info, lfname) <= 0) /* Return now if we have locked it, or if lock creation failed */ return; /* Else consider breaking the lock */ locker = (char *) alloca (strlen (lock_info.user) + strlen (lock_info.host) + LOCK_PID_MAX + 9); sprintf (locker, "%s@%s (pid %lu)", lock_info.user, lock_info.host, lock_info.pid); FREE_LOCK_INFO (lock_info); attack = call2 (intern ("ask-user-about-lock"), fn, build_string (locker)); if (!NILP (attack)) /* User says take the lock */ { lock_file_1 (lfname, 1); return; } /* User says ignore the lock */ }
static void call2(void) { static int i = 0; if (i != 10) call2(); printf("%d", i); i++; }
int my_getnbr(char *str) { int cpt1; int cpt2; cpt1 = 0; cpt2 = 0; while (str[cpt1] > '9' || str[cpt1] < '0') cpt1 = cpt1 + 1; while (str[cpt2 + cpt1] >= '0' && str[cpt2 + cpt1] <= '9') cpt2 = cpt2 + 1; return (call2(str, cpt1, cpt2)); }
int main() { CallHandler handler; handler.employ(new Fresher("Lily")); handler.employ(new Fresher("Ben")); handler.employ(new Fresher("Carlos")); handler.employ(new Fresher("David")); handler.employ(new Fresher("Thomas")); handler.employ(new TechLead("Anglela")); handler.employ(new ProductManager("Benson")); Call call1_1(CallHandler::FRESHER); Call call1_2(CallHandler::FRESHER); Call call1_3(CallHandler::FRESHER); Call call1_4(CallHandler::FRESHER); Call call1_5(CallHandler::FRESHER); Call call2(CallHandler::TECHLEAD); Call call3(CallHandler::TECHLEAD); Call call4(CallHandler::PRODUCTMANAGER); handler.dispatchCall(&call1_1); handler.dispatchCall(&call1_2); handler.dispatchCall(&call1_3); handler.dispatchCall(&call1_4); handler.dispatchCall(&call1_5); handler.dispatchCall(&call2); handler.dispatchCall(&call3); handler.dispatchCall(&call4); call1_1.disconnect(); call2.complain(); call3.disconnect(); // Call Handler updates and dispatch Call4 to ProductManager handler.update(); call4.disconnect(); // Call Handler updates and dispatch Call2 to ProductManager handler.update(); // Complain again, product manager just give up ... call2.complain(); // ... return 0; }
/* * Compare character(s) code. */ LOCAL NODE * putchcmp(struct bigblock *p) { NODE *p1, *p2, *p3; if(ISONE(p->b_expr.leftp->vleng) && ISONE(p->b_expr.rightp->vleng) ) { p1 = putaddr( putch1(p->b_expr.leftp) , YES ); p2 = putaddr( putch1(p->b_expr.rightp) , YES ); p3 = mkbinode(ops2[p->b_expr.opcode], p1, p2, CHAR); ckfree(p); } else { p->b_expr.leftp = call2(TYINT,"s_cmp", p->b_expr.leftp, p->b_expr.rightp); p->b_expr.rightp = MKICON(0); p3 = putop(p); } return p3; }
/* * Assign a character to another. */ LOCAL NODE * putcheq(struct bigblock *p) { NODE *p1, *p2, *p3; if( p->b_expr.rightp->tag==TEXPR && p->b_expr.rightp->b_expr.opcode==OPCONCAT ) p3 = putcat(p->b_expr.leftp, p->b_expr.rightp); else if( ISONE(p->b_expr.leftp->vleng) && ISONE(p->b_expr.rightp->vleng) ) { p1 = putaddr( putch1(p->b_expr.leftp) , YES ); p2 = putaddr( putch1(p->b_expr.rightp) , YES ); p3 = mkbinode(ASSIGN, p1, p2, CHAR); } else p3 = putx(call2(TYINT, "s_copy", p->b_expr.leftp, p->b_expr.rightp)); frexpr(p->vleng); ckfree(p); return p3; }
void main (void) { call1 (uchar0); call2 (uint0); uchar1 = call3 (); uint1 = call4 (); if (uint1) failures++; uint1 = call5 (uint0); if (uint1) failures++; if(call6(uchar0)) failures++; if(call7(0)) failures++; if(!call7(1)) failures++; if(!call7(0xff00)) failures++; uchar0=4; uchar1=3; uchar0 = call8(uchar0,uchar1); if(uchar0 != 7) failures++; call9(0x1234,0x5678); done (); }
sl_def(do_test, void) { #define x values[p].d #define xf values[p].f #define y values[p+1].d #define yf values[p+1].f #define n values[p+2].i #define nl values[p+2].l #define call1(F) \ values[p].desc = #F; \ values[p].d = F(x); \ ++p; \ values[p].desc = #F "f"; \ values[p].f = F ## f (xf); \ ++p #define call1i(F) \ values[p].desc = #F; \ values[p].i = F(x); \ ++p #define call2(F) \ values[p].desc = #F; \ values[p].d = F(x, y); \ p += 2; \ values[p].desc = #F "f"; \ values[p].f = F ## f (xf, yf); \ p += 2 #define call2i(F) \ values[p].desc = #F; \ values[p].i = F(x, y); \ p += 2; \ values[p].desc = #F "f"; \ values[p].i = F(xf, yf); \ p += 2 /* classify */ call1i(fpclassify); call1i(signbit); call1i(isfinite); call1i(isnormal); call1i(isnan); call1i(isinf); /* trig */ call1(acos); call1(asin); call1(atan); call2(atan2); call1(cos); call1(sin); call1(tan); /* hyperbolic */ call1(acosh); call1(asinh); call1(atanh); call1(cosh); call1(sinh); call1(tanh); /* exp/log */ call1(exp); call1(exp2); call1(expm1); values[p].desc = "frexp"; values[p].d = frexp(x, &values[p+1].i); p += 2; values[p].desc = "frexpf"; values[p].f = frexpf(xf, &values[p+1].i); p += 2; values[p].desc = "ilogb"; values[p].i = ilogb(x); p++; values[p].desc = "ilogbf"; values[p].i = ilogbf(xf); p++; values[p].desc = "ldexp"; values[p].d = ldexp(x, n); p+=3; values[p].desc = "ldexpf"; values[p].f = ldexpf(xf, n); p+=3; call1(log); call1(log10); call1(log1p); call1(log2); call1(logb); values[p].desc = "modf"; values[p].d = modf(x, &y); p += 2; values[p].desc = "modff"; values[p].f = modff(xf, &yf); p += 2; values[p].desc = "scalbn"; values[p].d = scalbn(x, n); p+=3; values[p].desc = "scalbnf"; values[p].f = scalbnf(xf, n); p+=3; values[p].desc = "scalbln"; values[p].d = scalbln(x, nl); p+=3; values[p].desc = "scalblnf"; values[p].f = scalblnf(xf, nl); p+=3; /* power/abs */ call1(cbrt); call1(fabs); call2(hypot); call2(pow); call1(sqrt); /* error/gamma */ call1(erf); call1(erfc); call1(lgamma); call1(tgamma); call1(ceil); call1(floor); call1(nearbyint); call1(rint); call1(lrint); values[p].desc = "lrint"; values[p].l = lrint(x); p++; values[p].desc = "lrintf"; values[p].l = lrintf(xf); p++; values[p].desc = "llrint"; values[p].ll = llrint(x); p++; values[p].desc = "llrintf"; values[p].ll = llrintf(xf); p++; call1(round); values[p].desc = "lround"; values[p].l = lround(x); p++; values[p].desc = "lroundf"; values[p].l = lroundf(xf); p++; values[p].desc = "llround"; values[p].ll = llround(x); p++; values[p].desc = "llroundf"; values[p].ll = llroundf(xf); p++; call1(trunc); /* rem/mod */ call2(fmod); call2(remainder); values[p].desc = "remquo"; values[p].d = remquo(x, y, &values[p+1].i); p+=2; values[p].desc = "remquof"; values[p].f = remquof(xf, yf, &values[p+1].i); p+=2; call2(copysign); /* nan */ values[p].desc = "nan"; values[p].d = nan(""); ++p; values[p].desc = "nanf"; values[p].f = nanf(""); ++p; call2(nextafter); /* min/max/dim */ call2(fdim); call2(fmax); call2(fmin); values[p].desc = "fma"; values[p].d = fma(x, y, values[p+2].d); p+=3; values[p].desc = "fmaf"; values[p].d = fmaf(xf, yf, values[p+2].f); p+=3; /* comp */ call2i(isgreater); call2i(isgreaterequal); call2i(isless); call2i(islessequal); call2i(islessgreater); call2i(isunordered); #undef x #undef xf #undef y #undef n }
void call1(void) { printk("Inside call1\r\n"); call2(); }
void call3(void) { LOG(INFO) << "Calling call2()"; call2(); }
ClientBackgroundManager::ClientBackgroundManager(QWidget *parent) : QWidget(parent) { serverIpLabel = new QLabel(tr("&Server IP:")); loginLabel = new QLabel(tr("&Login:"******"&Password:"******"89.103.183.36")); loginEdit = new QLineEdit(tr("client")); passwdEdit = new QLineEdit(tr("")); passwdEdit->setEchoMode(QLineEdit::Password); serverIpLabel->setBuddy(serverIpEdit); loginLabel->setBuddy(loginEdit); passwdLabel->setBuddy(passwdEdit); loginButton = new QPushButton(tr("Login")); loginButton->setEnabled(false); registerButton = new QPushButton(tr("Register")); registerButton->setEnabled(false); listHeaderlabel = new QLabel(tr("Seznam online klientu")); listHeaderlabel->setEnabled(false); myNewWidget = new QWidget(); insideArea = new QVBoxLayout(myNewWidget); myNewWidget->setLayout(insideArea); logoutButton = new QPushButton(tr("Logout")); logoutButton->setDefault(false); logoutButton->setEnabled(false); quitButton = new QPushButton(tr("Quit")); quitButton->setDefault(false); quitButton->setEnabled(false); connect(serverIpEdit, SIGNAL(textChanged(QString)), this, SLOT(enableSubmitButton())); connect(loginEdit, SIGNAL(textChanged(QString)), this, SLOT(enableSubmitButton())); connect(loginButton, SIGNAL(clicked()), this, SLOT(initLogin())); connect(registerButton, SIGNAL(clicked()), this, SLOT(initRegister())); connect(logoutButton, SIGNAL(clicked()), this, SLOT(logout())); connect(quitButton, SIGNAL(clicked()), this, SLOT(close())); //to server connect(this, SIGNAL(sendDataToServer(MessageEnvelop&)), &myClient2ServerThread, SLOT(sendMessageToServer(MessageEnvelop&)), Qt::DirectConnection); //from server connect(&myClient2ServerThread, SIGNAL(error(int, QString)), this, SLOT(displayError(int, QString))); connect(&myClient2ServerThread, SIGNAL(clientList(const QList<QString>)), this, SLOT(displayClientList(const QList<QString>)), Qt::DirectConnection); connect(&myClient2ServerThread, SIGNAL(incommingCall(const QString, const QHostAddress, const quint16, const quint16)), this, SLOT(incommingCall(const QString, const QHostAddress, const quint16, const quint16)), Qt::DirectConnection); connect(&myClient2ServerThread, SIGNAL(successResponseCall(const QString, const QHostAddress, const quint16, const quint16)), this, SLOT(successResponseCall(const QString, const QHostAddress, const quint16, const quint16)), Qt::DirectConnection); /*test*/callAnotherClient1 = new QPushButton(tr("call 1. client")); /*test*/callAnotherClient1->setDefault(true); /*test*/callAnotherClient1->setEnabled(true); /*test*/callAnotherClient2 = new QPushButton(tr("call 2. client")); /*test*/callAnotherClient2->setDefault(true); /*test*/callAnotherClient2->setEnabled(true); /*test*/connect(callAnotherClient1, SIGNAL(clicked()), this, SLOT(call1())); /*test*/connect(callAnotherClient2, SIGNAL(clicked()), this, SLOT(call2())); QGridLayout *mainLayout = new QGridLayout; mainLayout->addWidget(serverIpLabel, 0, 0); mainLayout->addWidget(serverIpEdit, 0, 1); mainLayout->addWidget(loginLabel, 1, 0); mainLayout->addWidget(loginEdit, 1, 1); mainLayout->addWidget(passwdLabel, 2, 0); mainLayout->addWidget(passwdEdit, 2, 1); mainLayout->addWidget(loginButton, 3, 0); mainLayout->addWidget(registerButton, 3, 1); mainLayout->addWidget(listHeaderlabel, 4, 0); mainLayout->addWidget(myNewWidget, 5, 0); /*test*/mainLayout->addWidget(callAnotherClient1, 6, 0); /*test*/mainLayout->addWidget(callAnotherClient2, 6, 1); mainLayout->addWidget(logoutButton, 7, 0); mainLayout->addWidget(quitButton, 7, 1); setLayout(mainLayout); setWindowTitle(tr("Penguin Client")); serverIpEdit->setFocus(); }