static AstExpression CheckConditionalExpression(AstExpression expr) { int qual; Type ty1, ty2; expr->kids[0] = Adjust(CheckExpression(expr->kids[0]), 1); if (! IsScalarType(expr->kids[0]->ty)) { Error(&expr->coord, "The first expression shall be scalar type."); } expr->kids[1]->kids[0] = Adjust(CheckExpression(expr->kids[1]->kids[0]), 1); expr->kids[1]->kids[1] = Adjust(CheckExpression(expr->kids[1]->kids[1]), 1); ty1 = expr->kids[1]->kids[0]->ty; ty2 = expr->kids[1]->kids[1]->ty; if (BothArithType(ty1, ty2)) { expr->ty = CommonRealType(ty1, ty2); expr->kids[1]->kids[0] = Cast(expr->ty, expr->kids[1]->kids[0]); expr->kids[1]->kids[1] = Cast(expr->ty, expr->kids[1]->kids[1]); return FoldConstant(expr); } else if (IsRecordType(ty1) && ty1 == ty2) { expr->ty = ty1; } else if (ty1->categ == VOID && ty2->categ == VOID) { expr->ty = T(VOID); } else if (IsCompatiblePtr(ty1, ty2)) { qual = ty1->bty->qual | ty2->bty->qual; expr->ty = PointerTo(Qualify(qual, CompositeType(Unqual(ty1->bty), Unqual(ty2->bty)))); } else if (IsPtrType(ty1) && IsNullConstant(expr->kids[1]->kids[1])) { expr->ty = ty1; } else if (IsPtrType(ty2) && IsNullConstant(expr->kids[1]->kids[0])) { expr->ty = ty2; } else if (NotFunctionPtr(ty1) && IsVoidPtr(ty2) || NotFunctionPtr(ty2) && IsVoidPtr(ty1)) { qual = ty1->bty->qual | ty2->bty->qual; expr->ty = PointerTo(Qualify(qual, T(VOID))); } else { Error(&expr->coord, "invalid operand for ? operator."); expr->ty = T(INT); } return expr; }
static errno_t __stdcall _FBTreeLoadRoot(_pFBTreeFileHead pHead) { _FBTreeFileNode node; _pFBTreeFileNodeEntry p1; int cnt; #ifdef OK_SYS_WINDOWS sqword fpos; #endif #ifdef OK_SYS_UNIX off_t fpos; #endif dword sz; dword ix; if ( pHead->fproot == 0 ) return EINVAL; #ifdef OK_SYS_WINDOWS fpos = _lseeki64(pHead->fd, pHead->fproot, SEEK_SET); #endif #ifdef OK_SYS_UNIX fpos = lseek(pHead->fd, pHead->fproot, SEEK_SET); #endif if ( 0 > fpos ) return errno; if ( Cast(qword,fpos) != pHead->fproot ) return EIO; cnt = _read(pHead->fd, &node, szFBTreeFileNode); if ( cnt < 0 ) return errno; if ( Cast(dword,cnt) < szFBTreeFileNode ) return EIO; node.head = pHead; node.parent = NULL; sz = szFBTreeFileNode + (pHead->maxEntriesPerNode * (szFBTreeFileNodeEntry + pHead->keySize)); pHead->root = CastAnyPtr(_FBTreeFileNode, TFalloc(sz)); if ( PtrCheck(pHead->root) ) return ENOMEM; s_memcpy_s(pHead->root, szFBTreeFileNode, &node, szFBTreeFileNode); if ( node.cnt > 0 ) { p1 = CastAnyPtr(_FBTreeFileNodeEntry, _l_ptradd(pHead->root, szFBTreeFileNode)); sz = node.cnt * (szFBTreeFileNodeEntry + pHead->keySize); cnt = _read(pHead->fd, p1, sz); if ( cnt < 0 ) return errno; if ( cnt < Cast(int, sz) ) return EIO; for ( ix = 0; ix < node.cnt; ++ix, p1 = CastAnyPtr(_FBTreeFileNodeEntry, _l_ptradd(p1, szFBTreeFileNodeEntry + pHead->keySize)) ) p1->next = NULL; }
bool TestDataStructuresParent::DeallocPTestDataStructuresSub(PTestDataStructuresSubParent* actor) { test_assert(Cast(actor).mI == Cast(mKids[0]).mI, "dtor sent to wrong actor"); mKids.RemoveElementAt(0); delete actor; if (mKids.Length() > 0) return true; return true; }
/** * Check argument. * @param fty function type * @param arg argument expression * @param argNo the argument's number in function call * @param argFull if the function's argument is full */ static AstExpression CheckArgument(FunctionType fty, AstExpression arg, int argNo, int *argFull) { Parameter param; int parLen = LEN(fty->sig->params); arg = Adjust(CheckExpression(arg), 1); if (fty->sig->hasProto && parLen == 0) { *argFull = 1; return arg; } if (argNo == parLen && ! fty->sig->hasEllipse) *argFull = 1; if (! fty->sig->hasProto) { arg = PromoteArgument(arg); if (parLen != 0) { param = GET_ITEM(fty->sig->params, argNo - 1); if (! IsCompatibleType(arg->ty, param->ty)) goto err; } return arg; } else if (argNo <= parLen) { param = GET_ITEM(fty->sig->params, argNo - 1); if (! CanAssign(param->ty, arg)) goto err; if (param->ty->categ < INT) arg = Cast(T(INT), arg); else arg = Cast(param->ty, arg); return arg; } else { return PromoteArgument(arg); } err: Error(&arg->coord, "Incompatible argument"); return arg; }
// Trace is the most fundamental of all the ray tracing functions. It // answers the query "What color do I see looking along the given ray // in the current scene?" This is an inherently recursive process, as // trace may again be called as a result of the ray hitting a reflecting // object. To prevent the possibility of infinite recursion, a maximum // depth is placed on the resulting ray tree. Color Raytracer::Trace( const Ray &ray, const Scene &scene, int max_tree_depth ) { Color color; // The color to return. HitInfo hitinfo; // Holds info to pass to shader. // Intitallizes hit distance to infinity to allow finding intersections in all ray length hitinfo.geom.distance = Infinity; if (Cast( ray, scene, hitinfo ) > 0.0f && max_tree_depth > -1 ) { // The ray hits an object, so shade the point that the ray hit. // Cast has put all necessary information for Shade in "hitinfo". // If the ray has no_emitters activated and the first hit is an emitter // this ray shouldn't contribute to the color of the current pixel if( hitinfo.material.Emitter() && ray.no_emitters == true ) color = Color (); // The ray hits an object, so shade the point that the ray hit. // Cast has put all necessary information for Shade in "hitinfo". else color = Shade( hitinfo, scene, max_tree_depth ); } else { // Either the ray has failed to hit anything, or // the recursion has bottomed out. color = scene.bgcolor; } return color; }
NS_IMETHODIMP BasePrincipal::EqualsConsideringDomain(nsIPrincipal *aOther, bool *aResult) { *aResult = Subsumes(aOther, ConsiderDocumentDomain) && Cast(aOther)->Subsumes(this, ConsiderDocumentDomain); return NS_OK; }
/* static */ int32_t PluginAsyncSurrogate::NPP_WriteReady(NPP aInstance, NPStream* aStream) { PluginAsyncSurrogate* surrogate = Cast(aInstance); MOZ_ASSERT(surrogate); return surrogate->NPP_WriteReady(aStream); }
/* static */ NPError PluginAsyncSurrogate::NPP_SetWindow(NPP aInstance, NPWindow* aWindow) { PluginAsyncSurrogate* surrogate = Cast(aInstance); MOZ_ASSERT(surrogate); return surrogate->NPP_SetWindow(aWindow); }
/* static */ int16_t PluginAsyncSurrogate::NPP_HandleEvent(NPP aInstance, void* aEvent) { PluginAsyncSurrogate* surrogate = Cast(aInstance); MOZ_ASSERT(surrogate); return surrogate->NPP_HandleEvent(aEvent); }
/* static */ void PluginAsyncSurrogate::NPP_Print(NPP aInstance, NPPrint* aPrintInfo) { PluginAsyncSurrogate* surrogate = Cast(aInstance); MOZ_ASSERT(surrogate); surrogate->NPP_Print(aPrintInfo); }
/* static */ NPError PluginAsyncSurrogate::NPP_SetValue(NPP aInstance, NPNVariable aVariable, void* aValue) { PluginAsyncSurrogate* surrogate = Cast(aInstance); MOZ_ASSERT(surrogate); return surrogate->NPP_SetValue(aVariable, aValue); }
/* static */ NPError PluginAsyncSurrogate::NPP_NewStream(NPP aInstance, NPMIMEType aType, NPStream* aStream, NPBool aSeekable, uint16_t* aStype) { PluginAsyncSurrogate* surrogate = Cast(aInstance); MOZ_ASSERT(surrogate); return surrogate->NPP_NewStream(aType, aStream, aSeekable, aStype); }
void SpellManager::Cast(MsgEntry* me, Client* client) { psSpellCastMessage msg(me); csString spellName = msg.spell; float kFactor = msg.kFactor; Cast(client->GetActor(), spellName, kFactor, client); }
/* static */ NPError PluginAsyncSurrogate::NPP_DestroyStream(NPP aInstance, NPStream* aStream, NPReason aReason) { PluginAsyncSurrogate* surrogate = Cast(aInstance); MOZ_ASSERT(surrogate); return surrogate->NPP_DestroyStream(aStream, aReason); }
/* static */ void PluginAsyncSurrogate::NotifyDestroyPending(NPP aInstance) { PluginAsyncSurrogate* surrogate = Cast(aInstance); if (!surrogate) { return; } surrogate->NotifyDestroyPending(); }
/*---------------------------------------------------------------------- * access vtable */ static inline const NGS_ReferenceSequence_v1_vt * Access ( const NGS_VTable * vt ) { const NGS_ReferenceSequence_v1_vt * out = static_cast < const NGS_ReferenceSequence_v1_vt* > ( Cast ( vt, NGS_ReferenceSequence_v1_tok ) ); if ( out == 0 ) throw ErrorMsg ( "object is not of type NGS_ReferenceSequence_v1" ); return out; }
ErrorCode ParserExpressionArithmetic::ConstantFoldPost() { ErrorCode er = NO_ERROR; // Get arguments std::vector<ParserNode*> children; this->GetChildren(&children); auto *left_child = children.at(0); auto *right_child = children.at(1); DatabaseValue result = DatabaseValue(); // If at least one of the children is NULL, then the result is a NULL value if (left_child->computed_value().is_null() || right_child->computed_value().is_null()) { this->computed_value().set_is_null(); return er; } switch (this->op()) { case PLUS: result = left_child->computed_value() + right_child->computed_value(); break; case MINUS: result = left_child->computed_value() - right_child->computed_value(); break; case MULTIPLY: result = left_child->computed_value() * right_child->computed_value(); break; case DIVIDE: result = left_child->computed_value() / right_child->computed_value(); break; case MODULO: if (left_child->computed_value().get_type()!= DB_INTEGER || right_child->computed_value().get_type() != DB_INTEGER) return ErrorManager::error(__HERE__, ER_ARITHMETIC_COMPUTATION, "MOD", "NON_INT", "NON_INT"); result = left_child->computed_value() % right_child->computed_value(); break; default: assert(false); return ER_FAILED; break; } if (result.get_type() == DB_ERROR) return ER_FAILED; this->set_computed_value(result); if (this->computed_value().get_type() != this->ExpectedType()){ auto aux = this->computed_value(); er = aux.Cast(this->ExpectedType()); if (er != NO_ERROR) return er; this->set_computed_value(aux); } return er; }
bool TestDataStructuresParent::RecvTest2( const InfallibleTArray<PTestDataStructuresSubParent*>& i1, InfallibleTArray<PTestDataStructuresSubParent*>* o1) { test_assert(nactors == i1.Length(), "wrong #actors"); for (uint32_t i = 0; i < i1.Length(); ++i) test_assert(i == Cast(i1[i]).mI, "wrong mI value"); *o1 = i1; return true; }
// static NPObject* PluginAsyncSurrogate::ScriptableAllocate(NPP aInstance, NPClass* aClass) { PLUGIN_LOG_DEBUG_FUNCTION; if (aClass != GetClass()) { NS_ERROR("Huh?! Wrong class!"); return nullptr; } return new AsyncNPObject(Cast(aInstance)); }
void UpdateAI(const uint32 uiDiff) { if (!m_creature->SelectHostileTarget() || !m_creature->getVictim()) return; //run on aggro if (m_creature->getVictim() && Move_Check) { m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); m_creature->GetMotionMaster()->MovePoint(0, WALKX_BLAU, WALKY_BLAU, WALKZ_BLAU); Move_Check = false; } // Cast if (Cast_Timer < uiDiff) { Unit *nearu = PickNearestPlayer(); Cast(nearu); }else Cast_Timer -= uiDiff; // Mark of Blaumeux if (Mark_Timer < uiDiff) { DoCast(m_creature->getVictim(),SPELL_MARK_OF_BLAUMEUX); Mark_Timer = 12000; }else Mark_Timer -= uiDiff; // Shield Wall - All 4 horsemen will shield wall at 50% hp and 20% hp for 20 seconds if (ShieldWall1 && m_creature->GetHealthPercent() < 50.0f) { if (ShieldWall1) { DoCast(m_creature,SPELL_SHIELDWALL); ShieldWall1 = false; } } if (ShieldWall2 && m_creature->GetHealthPercent() < 20.0f) { if (ShieldWall2) { DoCast(m_creature,SPELL_SHIELDWALL); ShieldWall2 = false; } } // Void Zone if (VoidZone_Timer < uiDiff) { DoCast(m_creature->getVictim(),SPELL_VOIDZONE); VoidZone_Timer = 12000; }else VoidZone_Timer -= uiDiff; }
//========================================================= bool Parser::Expression7 () { PrintRule rule("Expression7"); if (Value() == false) { return false; } while ( MemberAccess() || Call() || Cast() || Index() ); return rule.Accept(); }
void CMobController::CastSpell(uint16 spellid) { CSpell* PSpell = spell::GetSpell(spellid); if (PSpell == nullptr) { ShowWarning(CL_YELLOW"ai_mob_dummy::CastSpell: SpellId <%i> is not found\n" CL_RESET, spellid); } else { CBattleEntity* PCastTarget = nullptr; // check valid targets if (PSpell->getValidTarget() & TARGET_SELF) { PCastTarget = PMob; // only buff other targets if i'm roaming if ((PSpell->getValidTarget() & TARGET_PLAYER_PARTY)) { // chance to target my master if (PMob->PMaster != nullptr && dsprand::GetRandomNumber(2) == 0) { // target my master PCastTarget = PMob->PMaster; } else if (dsprand::GetRandomNumber(2) == 0) { // chance to target party PMob->PAI->TargetFind->reset(); PMob->PAI->TargetFind->findWithinArea(PMob, AOERADIUS_ATTACKER, PSpell->getRange()); if (!PMob->PAI->TargetFind->m_targets.empty()) { // randomly select a target PCastTarget = PMob->PAI->TargetFind->m_targets[dsprand::GetRandomNumber(PMob->PAI->TargetFind->m_targets.size())]; // only target if are on same action if (PMob->PAI->IsEngaged() == PCastTarget->PAI->IsEngaged()) { PCastTarget = PMob; } } } } } else { PCastTarget = PTarget; } Cast(PCastTarget->targid, spellid); } }
// ************************************************************* // GetColorMatrix() // ************************************************************* Gdiplus::ColorMatrix ImageHelper::GetColorMatrix(IImage* img) { if (!img) { Gdiplus::ColorMatrix matrix; ZeroMemory((void*)&matrix.m, 25 * sizeof(REAL)); for (int i = 0; i < 5; i++) matrix.m[i][i] = 1.0f; matrix.m[3][3] = 1.0f; return matrix; } return Cast(img)->GetColorMatrix(); }
static AstExpression CheckTypeCast(AstExpression expr) { Type ty; ty = CheckTypeName((AstTypeName)expr->kids[0]); expr->kids[1] = Adjust(CheckExpression(expr->kids[1]), 1); if (! (BothScalarType(ty, expr->kids[1]->ty) || ty->categ == VOID)) { Error(&expr->coord, "Illegal type cast"); return expr->kids[1]; } return Cast(ty, expr->kids[1]); }
int KThiefSkill::OnSkill(KNpc * pNpc) { _ASSERT(pNpc); if (!pNpc) return 0; KPlayer * pLauncherPlayer = NULL; KPlayer * pTargetPlayer = NULL; #ifndef _SERVER pNpc->m_DataRes.SetBlur(FALSE); #endif if (pNpc->m_DesX == -1) { if (pNpc->m_DesY <= 0) goto Label_ProcessAI1; //此时该角色已经无效时 if (Npc[pNpc->m_DesY].m_RegionIndex < 0) goto Label_ProcessAI1; } if (pNpc->m_nPlayerIdx < 0 || pNpc->m_DesY < 0 || pNpc->m_DesY >= MAX_NPC #ifdef _SERVER || Npc[pNpc->m_DesY].m_nPlayerIdx < 0 #endif ) goto Label_ProcessAI1; pLauncherPlayer = &Player[pNpc->m_nPlayerIdx]; pTargetPlayer = &Player[Npc[pNpc->m_DesY].m_nPlayerIdx]; Cast(pLauncherPlayer, pTargetPlayer); pNpc->m_SkillList.SetNextCastTime(pNpc->m_ActiveSkillID, SubWorld[pNpc->m_SubWorldIndex].m_dwCurrentTime + GetDelayPerCast()); Label_ProcessAI1: if (pNpc->m_Frames.nTotalFrame == 0) { pNpc->m_ProcessAI = 1; } return 1; }
VkResult CommandPool::reset(VkCommandPoolResetFlags flags) { // According the Vulkan 1.1 spec: // "All command buffers that have been allocated from // the command pool are put in the initial state." for(auto commandBuffer : *commandBuffers) { Cast(commandBuffer)->reset(flags); } // According the Vulkan 1.1 spec: // "Resetting a command pool recycles all of the // resources from all of the command buffers allocated // from the command pool back to the command pool." commandBuffers->clear(); return VK_SUCCESS; }
bool pawsSpellBookWindow::OnButtonPressed(int /*mouseButton*/, int /*keyModifier*/, pawsWidget* widget) { if (!strcmp(widget->GetName(),"Combine")) { CreateNewSpell(); return true; } else if (!strcmp(widget->GetName(),"Cast")) { Cast(); return true; } else if (!strcmp(widget->GetName(),"ActiveMagic")) { ShowActiveMagic(); return true; } return true; }
static AstExpression CheckAssignmentExpression(AstExpression expr) { int ops[] = { OP_BITOR, OP_BITXOR, OP_BITAND, OP_LSHIFT, OP_RSHIFT, OP_ADD, OP_SUB, OP_MUL, OP_DIV, OP_MOD }; Type ty; expr->kids[0] = Adjust(CheckExpression(expr->kids[0]), 0); expr->kids[1] = Adjust(CheckExpression(expr->kids[1]), 1); if (! CanModify(expr->kids[0])) { Error(&expr->coord, "The left operand cannot be modified"); } if (expr->op != OP_ASSIGN) { AstExpression lopr; CREATE_AST_NODE(lopr, Expression); lopr->coord = expr->coord; lopr->op = ops[expr->op - OP_BITOR_ASSIGN]; lopr->kids[0] = expr->kids[0]; lopr->kids[1] = expr->kids[1]; expr->kids[1] = (*BinaryOPCheckers[lopr->op - OP_OR])(lopr); } ty = expr->kids[0]->ty; if (! CanAssign(ty, expr->kids[1])) { Error(&expr->coord, "Wrong assignment"); } else { expr->kids[1] = Cast(ty, expr->kids[1]); } expr->ty = ty; return expr; }
static void Interpret(std::byte *target_data, enum _Interchange_buffer::pixel_layout target_layout, enum _Interchange_buffer::alpha_mode target_alpha_mode, int target_stride, const std::byte *source_data, enum _Interchange_buffer::pixel_layout source_layout, enum _Interchange_buffer::alpha_mode source_alpha_mode, int source_width, int source_height, int source_stride) noexcept { const auto dst_bpp = BytesPerPixel(target_layout); const auto src_bpp = BytesPerPixel(source_layout); for( int row = 0; row < source_height; ++row ) { for( int column = 0; column < source_width; ++column ) { auto src = source_data + row * source_stride + column * src_bpp; auto dst = target_data + row * target_stride + column * dst_bpp; Cast(dst, target_layout, target_alpha_mode, src, source_layout, source_alpha_mode); } } }
/* static */ NPError PluginAsyncSurrogate::NPP_Destroy(NPP aInstance, NPSavedData** aSave) { PluginAsyncSurrogate* rawSurrogate = Cast(aInstance); MOZ_ASSERT(rawSurrogate); PluginModuleParent* module = rawSurrogate->GetParent(); if (module && !module->IsInitialized()) { // Take ownership of pdata's surrogate since we're going to release it nsRefPtr<PluginAsyncSurrogate> surrogate(dont_AddRef(rawSurrogate)); aInstance->pdata = nullptr; // We haven't actually called NPP_New yet, so we should remove the // surrogate for this instance. bool removeOk = module->RemovePendingSurrogate(surrogate); MOZ_ASSERT(removeOk); if (!removeOk) { return NPERR_GENERIC_ERROR; } surrogate->mInitCancelled = true; return NPERR_NO_ERROR; } return rawSurrogate->NPP_Destroy(aSave); }