void CCobInstance::EndTransport() { Call(COBFN_EndTransport); }
int CWorkerThread::CallWorker(unsigned dw, unsigned timeout, bool fBoostWorkerPriorityToMaster) { return Call(dw, timeout, fBoostWorkerPriorityToMaster); }
/* this will be replaced with something more sophisticated later */ void ActionSelector::evalMagic(int potSize, bool myButton, const std::vector<std::string> &boardCards, const std::vector<std::string> &holeCards, const std::string &myDiscard, const ActionSelector::LegalAction &legalAction, ActionSelector::ActionInfo &actionInfo, float equity){ int coin = rand() % 3; //LOL int callMin = legalAction.callMin; if (coin == 1 && equity > 0.8){ if (legalAction.raiseMax > 0){ if (legalAction.actionType == CHECK_BET) Bet(actionInfo, legalAction.raiseMax); else Raise(actionInfo, legalAction.raiseMax); } else { std::cout << "ActionSelector.cpp:L78 Calling All-in" << std::endl; Call(actionInfo); } //std::cout << "raising to " << actionInfo.betAmount << std::endl; return; } // compute pot odds and either call or fold float potOdds = (float)callMin/(callMin+potSize); bool canRaise=legalAction.raiseMax>0, isAllin=legalAction.raiseMax==0, mustCall=legalAction.callMin>0; // raise with the worst and best cards in our range if (equity>0.62){ std::cout << "myPotOdds: " << callMin << "/" << (callMin+potSize) << ":" << potOdds << " vs. equity: " << equity << std::endl; if (legalAction.raiseMax > 0){ float oppEquity=1-equity; int newPotSize=callMin+potSize; int raise=(int)((newPotSize*equity/oppEquity)) + callMin; // int raise=(int)((newPotSize*equity/oppEquity)) + callMin; int numBoardCards = boardCards.size(); if (numBoardCards >= 3) raise = 7; //7std::max(raise, 100); // so we actually can make money if (numBoardCards >= 4 && equity > 0.7) raise = std::max(raise, 200); if (numBoardCards >= 5 && equity > 0.85) raise = std::max(raise, 300); int betAmt= std::max(std::min(raise,legalAction.raiseMax), legalAction.raiseMin); std::cout << "betAmt: " << betAmt << " vs. raise: " << raise << "(raiseMin, max) " << legalAction.raiseMin << ", " << legalAction.raiseMax << std::endl; if (betAmt){ actionInfo.action= (legalAction.actionType == CHECK_BET) ? BET : RAISE; actionInfo.betAmount=betAmt; } else { actionInfo.action = (legalAction.actionType == CHECK_BET) ? CHECK : FOLD; actionInfo.betAmount=0; }//end if(betAmt) } else { if ((legalAction.callMin > 100 && equity < 0.65)) Fold(actionInfo); else Call(actionInfo); } //end if(raisMax > 0) }else{ std::cout << "myPotOdds: " << callMin << "/" << (callMin+potSize) << ":" << potOdds << " vs. equity: " << equity << std::endl; float roundDiscount=0; int numBoardCards = boardCards.size(); // Discount our equity, so we are less willing to call with low equity on later streets (especially the river) if (numBoardCards == 5){ roundDiscount=0.2; } if (legalAction.callMin > 0){ if (numBoardCards>=3 && equity < 0.55){ // fold if our equity is bad by the turn Fold(actionInfo); }else if (equity-roundDiscount>(potOdds)+0.04){ //less likely to call if we are down Call(actionInfo); } else { Fold(actionInfo); } } else { Check(actionInfo); } } }
//================================================================ // main function //================================================================ int #ifndef __ANSI__ __cdecl #endif // __ANSI__ main(int argc, char* argv[]) { if (argc != 5) { fprintf(stderr, "Required arguments:\n"); fprintf(stderr, "1. JPEG quality value, 0-100\n"); fprintf(stderr, "2. Image size (e.g. '512x512')\n"); fprintf(stderr, "3. Path to YUV input file\n"); fprintf(stderr, "4. Path to JXR output file\n"); return 1; } errno = 0; long quality = strtol(argv[1], NULL, 10); if (errno != 0 || quality < 0 || quality > 100) { fprintf(stderr, "Invalid JPEG quality value!\n"); return 1; } const char *size = argv[2]; const char *x = strchr(size, 'x'); if (!x && x != size && x != (x + strlen(x) - 1)) { fprintf(stderr, "Invalid image size input!\n"); return 1; } long width = strtol(size, NULL, 10); if (errno != 0) { fprintf(stderr, "Invalid image size input!\n"); return 1; } long height = strtol(x + 1, NULL, 10); if (errno != 0) { fprintf(stderr, "Invalid image size input!\n"); return 1; } /* Right now we only support dimensions that are multiples of 16. */ if ((width % 16) != 0 || (height % 16) != 0) { fprintf(stderr, "Image dimensions must be multiples of 16!\n"); return 1; } /* Will check these for validity when opening via 'fopen'. */ const char *yuv_path = argv[3]; const char *jxr_path = argv[4]; int yuv_size = width*height+2*(width>>1)*(height>>1); unsigned char *image_buffer = (unsigned char*)malloc(yuv_size); // set encoder parameters including quality { CWMIStrCodecParam params; init_encoder_params(¶ms, quality); // run encoder ERR err; PKFactory* pFactory = NULL; PKCodecFactory* pCodecFactory = NULL; struct WMPStream* pEncodeStream = NULL; PKImageEncode* pEncoder = NULL; const PKIID* pIID = NULL; struct WMPStream* pDecodeStream = NULL; PKImageDecode* pDecoder = NULL; Call( PKCreateFactory(&pFactory, PK_SDK_VERSION) ); Call( pFactory->CreateStreamFromFilename(&pEncodeStream, jxr_path, "wb") ); Call( pFactory->CreateStreamFromFilename(&pDecodeStream, yuv_path, "rb") ); // decode PKRect rc; rc.X = 0; rc.Y = 0; rc.Width = width; rc.Height = height; Call( GetTestDecodeIID(".iyuv", &pIID) ); Call( PKTestFactory_CreateCodec(pIID, (void **) &pDecoder) ); Call( pDecoder->Initialize(pDecoder, pDecodeStream) ); pDecoder->uWidth = width; pDecoder->uHeight = height; Call( pDecoder->Copy(pDecoder, &rc, (U8*)image_buffer, width) ); Call( PKCreateCodecFactory(&pCodecFactory, WMP_SDK_VERSION) ); Call( pCodecFactory->CreateCodec(&IID_PKImageWmpEncode, (void**)&pEncoder) ); Call( pEncoder->Initialize(pEncoder, pEncodeStream, ¶ms, sizeof(params)) ); Call( pEncoder->SetPixelFormat(pEncoder, GUID_PKPixelFormat12bppYCC420) ); Call( pEncoder->SetSize(pEncoder, width, height) ); Call( pEncoder->WritePixels(pEncoder, height, (U8*)image_buffer, width*3) ); Cleanup: if( pDecoder ) pDecoder->Release(&pDecoder); if( pEncoder ) pEncoder->Release(&pEncoder); if( pCodecFactory ) pCodecFactory->Release(&pCodecFactory); if( pFactory ) pFactory->Release(&pFactory); } free(image_buffer); return 0; }
LRESULT CWndSubclasser::Default() { LRESULT r = Call(_token); //will process the next il list (if any) return r; }
void SpeedSelectorAction::syncSpeeds (int s) { Call ([s] (QComboBox *box) { box->setCurrentIndex (s); }); emit currentIndexChanged (s); }
ILboolean iLoadWdpInternal(/*ILconst_string FileName*/) { ERR err = WMP_errSuccess; PKFactory* pFactory = NULL; PKCodecFactory* pCodecFactory = NULL; PKImageDecode* pDecoder = NULL; PKPixelInfo PI; PKPixelFormatGUID guidPixFormat; PKFormatConverter* pConverter = NULL; U32 cFrame = 0, i = 0; PKRect Rect; struct WMPStream* pEncodeStream = NULL; PKImageEncode* pEncoder = NULL; //Call(PKCreateFactory(&pFactory, PK_SDK_VERSION)); //Call(PKCreateCodecFactory(&pCodecFactory, WMP_SDK_VERSION)); //Call(pCodecFactory->CreateDecoderFromFile(FileName, &pDecoder)); Call(ilPKCreateFactory(&pFactory, PK_SDK_VERSION)); Call(PKCreateCodecFactory(&pCodecFactory, WMP_SDK_VERSION)); Call(ilPKCodecFactory_CreateDecoderFromFile(&pDecoder)); //guidPixFormat = GUID_PKPixelFormat24bppRGB; guidPixFormat = GUID_PKPixelFormat32bppBGRA; //guidPixFormat = GUID_PKPixelFormat8bppGray; //guidPixFormat = GUID_PKPixelFormat16bppGray; // Color transcoding if (IsEqualGUID(&guidPixFormat, &GUID_PKPixelFormat8bppGray) || IsEqualGUID(&guidPixFormat, &GUID_PKPixelFormat16bppGray)){ // ** => Y transcoding pDecoder->guidPixFormat = guidPixFormat; pDecoder->WMP.wmiI.cfColorFormat = Y_ONLY; } else if(IsEqualGUID(&guidPixFormat, &GUID_PKPixelFormat24bppRGB) && pDecoder->WMP.wmiI.cfColorFormat == CMYK){ // CMYK = > RGB pDecoder->WMP.wmiI.cfColorFormat = CF_RGB; pDecoder->guidPixFormat = guidPixFormat; pDecoder->WMP.wmiI.bRGB = 1; //RGB } PI.pGUIDPixFmt = &guidPixFormat; PixelFormatLookup(&PI, LOOKUP_FORWARD); pDecoder->WMP.wmiSCP.bfBitstreamFormat = 0; pDecoder->WMP.wmiSCP.uAlphaMode = 0; pDecoder->WMP.wmiSCP.sbSubband = SB_ALL; pDecoder->WMP.bIgnoreOverlap = FALSE; pDecoder->WMP.wmiI.cfColorFormat = PI.cfColorFormat; pDecoder->WMP.wmiI.bdBitDepth = PI.bdBitDepth; pDecoder->WMP.wmiI.cBitsPerUnit = PI.cbitUnit; //==== Validate thumbnail decode parameters ===== pDecoder->WMP.wmiI.cThumbnailWidth = pDecoder->WMP.wmiI.cWidth; pDecoder->WMP.wmiI.cThumbnailHeight = pDecoder->WMP.wmiI.cHeight; pDecoder->WMP.wmiI.bSkipFlexbits = FALSE; pCodecFactory->CreateFormatConverter(&pConverter); pConverter->Initialize(pConverter, pDecoder, NULL, guidPixFormat); // Right now, we are just assuming one frame. // @TODO: Deal with multiple frames. //pDecoder->GetFrameCount(pDecoder, &cFrame); //pDecoder->SelectFrame(pDecoder, 1); if (!ilTexImage(pDecoder->uWidth, pDecoder->uHeight, 1, 4, IL_BGRA, IL_UNSIGNED_BYTE, NULL)) goto Cleanup; //ilTexImage(pDecoder->uWidth, pDecoder->uHeight, 1, 1, IL_LUMINANCE, IL_UNSIGNED_BYTE, Data); pFactory->CreateStreamFromMemory(&pEncodeStream, iCurImage->Data, iCurImage->SizeOfData); iWmpDecAppCreateEncoderFromExt(pCodecFactory, ".wdp", &pEncoder); pEncoder->Initialize(pEncoder, pEncodeStream, ".wdp", 0); pEncoder->pStream->GetPos(pEncoder->pStream, &pEncoder->offStart); // Set the region that we want to be the whole image. Rect.X = 0; Rect.Y = 0; Rect.Height = pDecoder->uHeight; Rect.Width = pDecoder->uWidth; pEncoder->SetPixelFormat(pEncoder, guidPixFormat); pEncoder->SetSize(pEncoder, Rect.Width, Rect.Height); pEncoder->WriteSource = PKImageEncode_Transcode; pEncoder->WriteSource(pEncoder, pConverter, &Rect); Cleanup: // Release everything all at the end. PKImageDecode_Release(&pDecoder); if (pEncoder) PKImageEncode_Release(&pEncoder); PKCreateCodecFactory_Release(&pCodecFactory); PKCreateFactory_Release(&pFactory); PKFormatConverter_Release(&pConverter); if (err != WMP_errSuccess) return IL_FALSE; return IL_TRUE; }
void CCobInstance::MoveRate(int curRate) { Call(COBFN_MoveRate0 + curRate); }
void CCobInstance::FireWeapon(int weaponNum) { Call(COBFN_FirePrimary + COBFN_Weapon_Funcs * weaponNum); }
void CCobInstance::Activate() { Call(COBFN_Activate); }
void CCobInstance::Deactivate() { Call(COBFN_Deactivate); }
void CCobInstance::Landed() { Call(COBFN_Landed); }
void CCobInstance::Falling() { Call(COBFN_Falling); }
void CCobInstance::StopBuilding() { Call(COBFN_StopBuilding); }
void WrapperPromiseCallback::Call(JS::Handle<JS::Value> aValue) { // AutoCxPusher and co. interact with xpconnect, which crashes on // workers. On workers we'll get the right context from // GetDefaultJSContextForThread(), and since there is only one context, we // don't need to push or pop it from the stack. JSContext* cx = nsContentUtils::GetDefaultJSContextForThread(); Maybe<AutoCxPusher> pusher; if (NS_IsMainThread()) { pusher.construct(cx); } Maybe<JSAutoCompartment> ac; EnterCompartment(ac, cx, aValue); ErrorResult rv; // If invoking callback threw an exception, run resolver's reject with the // thrown exception as argument and the synchronous flag set. JS::Rooted<JS::Value> value(cx, mCallback->Call(aValue, rv, CallbackObject::eRethrowExceptions)); rv.WouldReportJSException(); if (rv.Failed() && rv.IsJSException()) { JS::Rooted<JS::Value> value(cx); rv.StealJSException(cx, &value); Maybe<JSAutoCompartment> ac2; EnterCompartment(ac2, cx, value); mNextPromise->RejectInternal(cx, value, Promise::SyncTask); return; } // If the return value is the same as the promise itself, throw TypeError. if (value.isObject()) { JS::Rooted<JSObject*> valueObj(cx, &value.toObject()); Promise* returnedPromise; nsresult r = UNWRAP_OBJECT(Promise, valueObj, returnedPromise); if (NS_SUCCEEDED(r) && returnedPromise == mNextPromise) { const char* fileName = nullptr; uint32_t lineNumber = 0; // Try to get some information about the callback to report a sane error, // but don't try too hard (only deals with scripted functions). JS::Rooted<JSObject*> unwrapped(cx, js::CheckedUnwrap(mCallback->Callback())); if (unwrapped) { JSAutoCompartment ac(cx, unwrapped); if (JS_ObjectIsFunction(cx, unwrapped)) { JS::Rooted<JS::Value> asValue(cx, JS::ObjectValue(*unwrapped)); JS::Rooted<JSFunction*> func(cx, JS_ValueToFunction(cx, asValue)); MOZ_ASSERT(func); JSScript* script = JS_GetFunctionScript(cx, func); if (script) { fileName = JS_GetScriptFilename(cx, script); lineNumber = JS_GetScriptBaseLineNumber(cx, script); } } } // We're back in aValue's compartment here. JS::Rooted<JSString*> stack(cx, JS_GetEmptyString(JS_GetRuntime(cx))); JS::Rooted<JSString*> fn(cx, JS_NewStringCopyZ(cx, fileName)); if (!fn) { // Out of memory. Promise will stay unresolved. JS_ClearPendingException(cx); return; } JS::Rooted<JSString*> message(cx, JS_NewStringCopyZ(cx, "then() cannot return same Promise that it resolves.")); if (!message) { // Out of memory. Promise will stay unresolved. JS_ClearPendingException(cx); return; } JS::Rooted<JS::Value> typeError(cx); if (!JS::CreateTypeError(cx, stack, fn, lineNumber, 0, nullptr, message, &typeError)) { // Out of memory. Promise will stay unresolved. JS_ClearPendingException(cx); return; } mNextPromise->RejectInternal(cx, typeError, Promise::SyncTask); return; } } // Otherwise, run resolver's resolve with value and the synchronous flag // set. Maybe<JSAutoCompartment> ac2; EnterCompartment(ac2, cx, value); mNextPromise->ResolveInternal(cx, value, Promise::SyncTask); }
void CCobInstance::EndBurst(int weaponNum) { Call(COBFN_EndBurst + COBFN_Weapon_Funcs * weaponNum); }
void SimpleWrapperPromiseCallback::Call(JS::Handle<JS::Value> aValue) { ErrorResult rv; mCallback->Call(mPromise, aValue, rv); }
int CCobInstance::Call(const string &fname) { vector<int> x; return Call(fname, x, NULL, NULL, NULL); }
/** enqueue a set of variants */ void VariantCallsOnly::add(Variants const & v) { if (_impl->buffered_variants.size() > 0 && v.chr == _impl->buffered_variants.back().chr && v.pos < _impl->buffered_variants.back().pos) { error("Variant added out of order at %s:%i / %i", v.chr.c_str(), v.pos, _impl->buffered_variants.back().pos); } // // keep fails if(v.getInfoFlag("IMPORT_FAIL")) { #ifdef DEBUG_VARIANTCALLSONLY std::cerr << "fail-pass-on: " << v << "\n"; #endif _impl->buffered_variants.push_back(v); return; } #ifdef DEBUG_VARIANTCALLSONLY std::cerr << "Variants added: " << v << "\n"; #endif if (v.anyHomref()) { Variants non_hr = v; int n_non_hr = (int) v.calls.size(); for (size_t q = 0; q < v.calls.size(); ++q) { if(v.calls[q].isHomref()) { non_hr.calls[q] = Call(); _impl->homref_ivs.addInterval(v.pos, v.pos + v.len - 1, q); // remember dp if(q >= _impl->homref_dp.size()) { _impl->homref_dp.resize(q+1); } _impl->homref_dp[q].set(v.calls[q].dp, v.pos, v.pos + v.len - 1); --n_non_hr; } else if(v.calls[q].isNocall()) { --n_non_hr; } } if (n_non_hr || non_hr.anyAmbiguous()) { #ifdef DEBUG_VARIANTCALLSONLY std::cerr << "non-hr-add: " << v << "\n"; #endif _impl->buffered_variants.push_back(non_hr); } } else { #ifdef DEBUG_VARIANTCALLSONLY std::cerr << "non-hr-pass-on: " << v << "\n"; #endif _impl->buffered_variants.push_back(v); } }
int CCobInstance::Call(const string &fname, vector<int> &args) { return Call(fname, args, NULL, NULL, NULL); }
void SimpleWrapperPromiseCallback::Call(const Optional<JS::Handle<JS::Value> >& aValue) { ErrorResult rv; mCallback->Call(mPromise, aValue, rv); }
int CCobInstance::Call(const string &fname, int p1) { vector<int> x; x.push_back(p1); return Call(fname, x, NULL, NULL, NULL); }
TEST_F(APZHitTestingTester, TestRepaintFlushOnNewInputBlock) { SCOPED_GFX_PREF(TouchActionEnabled, bool, false); // The main purpose of this test is to verify that touch-start events (or anything // that starts a new input block) don't ever get untransformed. This should always // hold because the APZ code should flush repaints when we start a new input block // and the transform to gecko space should be empty. CreateSimpleScrollingLayer(); ScopedLayerTreeRegistration registration(manager, 0, root, mcc); manager->UpdateHitTestingTree(nullptr, root, false, 0, 0); TestAsyncPanZoomController* apzcroot = ApzcOf(root); // At this point, the following holds (all coordinates in screen pixels): // layers[0] has content from (0,0)-(500,500), clipped by composition bounds (0,0)-(200,200) MockFunction<void(std::string checkPointName)> check; { InSequence s; EXPECT_CALL(*mcc, RequestContentRepaint(_)).Times(AtLeast(1)); EXPECT_CALL(check, Call("post-first-touch-start")); EXPECT_CALL(*mcc, RequestContentRepaint(_)).Times(AtLeast(1)); EXPECT_CALL(check, Call("post-second-fling")); EXPECT_CALL(*mcc, RequestContentRepaint(_)).Times(AtLeast(1)); EXPECT_CALL(check, Call("post-second-touch-start")); } // This first pan will move the APZC by 50 pixels, and dispatch a paint request. ApzcPanNoFling(apzcroot, 100, 50); // Verify that a touch start doesn't get untransformed ScreenIntPoint touchPoint(50, 50); MultiTouchInput mti = CreateMultiTouchInput(MultiTouchInput::MULTITOUCH_START, mcc->Time()); mti.mTouches.AppendElement(SingleTouchData(0, touchPoint, ScreenSize(0, 0), 0, 0)); EXPECT_EQ(nsEventStatus_eConsumeDoDefault, manager->ReceiveInputEvent(mti, nullptr, nullptr)); EXPECT_EQ(touchPoint, mti.mTouches[0].mScreenPoint); check.Call("post-first-touch-start"); // Send a touchend to clear state mti.mType = MultiTouchInput::MULTITOUCH_END; manager->ReceiveInputEvent(mti, nullptr, nullptr); mcc->AdvanceByMillis(1000); // Now do two pans. The first of these will dispatch a repaint request, as above. // The second will get stuck in the paint throttler because the first one doesn't // get marked as "completed", so this will result in a non-empty LD transform. // (Note that any outstanding repaint requests from the first half of this test // don't impact this half because we advance the time by 1 second, which will trigger // the max-wait-exceeded codepath in the paint throttler). ApzcPanNoFling(apzcroot, 100, 50); check.Call("post-second-fling"); ApzcPanNoFling(apzcroot, 100, 50); // Ensure that a touch start again doesn't get untransformed by flushing // a repaint mti.mType = MultiTouchInput::MULTITOUCH_START; EXPECT_EQ(nsEventStatus_eConsumeDoDefault, manager->ReceiveInputEvent(mti, nullptr, nullptr)); EXPECT_EQ(touchPoint, mti.mTouches[0].mScreenPoint); check.Call("post-second-touch-start"); mti.mType = MultiTouchInput::MULTITOUCH_END; EXPECT_EQ(nsEventStatus_eConsumeDoDefault, manager->ReceiveInputEvent(mti, nullptr, nullptr)); EXPECT_EQ(touchPoint, mti.mTouches[0].mScreenPoint); }
int CCobInstance::Call(int id) { vector<int> x; return Call(id, x, NULL, NULL, NULL); }
/* void Join(int i){ Global ++; INTERLEV_ACCESS(0,"cs1.Call,cs3.Join","0,1,2"); pthread_join(t[i], NULL); Global ++; INTERLEV_ACCESS(0,"cs1.Call,cs3.Join","0,1,2"); } */ void Call2(int tid){ Call(tid); }
int CCobInstance::Call(int id, int p1) { vector<int> x; x.push_back(p1); return Call(id, x, NULL, NULL, NULL); }
int CWorkerThread::CallMaster(unsigned dw, unsigned timeout) { return Call(dw, timeout, false); }
int CCobInstance::Call(int id, vector<int> &args) { return Call(id, args, NULL, NULL, NULL); }
JObject JObject::CallOk(JObject& this_, JArgList& arg) { JResult jres = Call(this_, arg); IOTJS_ASSERT(jres.IsOk()); return jres.value(); }
void CCobInstance::StartUnload() { Call(COBFN_StartUnload); }