Modifier *CMaxMesh::FindSkinModifier(INode *pINode) { #if MAX_RELEASE >= 4000 // get the object reference of the node Object *pObject; pObject = pINode->GetObjectRef(); if(pObject == 0) return 0; // loop through all derived objects while(pObject->SuperClassID() == GEN_DERIVOB_CLASS_ID) { IDerivedObject *pDerivedObject; pDerivedObject = static_cast<IDerivedObject *>(pObject); // loop through all modifiers int stackId; for(stackId = 0; stackId < pDerivedObject->NumModifiers(); stackId++) { // get the modifier Modifier *pModifier; pModifier = pDerivedObject->GetModifier(stackId); // check if we found the skin modifier if(pModifier->ClassID() == SKIN_CLASSID) return pModifier; } // continue with next derived object pObject = pDerivedObject->GetObjRef(); } #endif return 0; }
// <ARGUMENT> void SettingLoader::load_ARGUMENT(Modifier *o_arg) { Modifier modifier; for (int i = Modifier::Type_begin; i != Modifier::Type_end; ++ i) modifier.dontcare(static_cast<Modifier::Type>(i)); *o_arg = load_MODIFIER(Modifier::Type_ASSIGN, modifier); }
bool ValueRef::getImmediate(ImmediateValue &imm) const { const ValueRef *src = this; Modifier m; DataType type = src->insn->sType; while (src) { if (src->mod) { if (src->insn->sType != type) break; m *= src->mod; } if (src->getFile() == FILE_IMMEDIATE) { imm = *(src->value->asImm()); // The immediate's type isn't required to match its use, it's // more of a hint; applying a modifier makes use of that hint. imm.reg.type = type; m.applyTo(imm); return true; } Instruction *insn = src->value->getUniqueInsn(); if (insn && insn->op == OP_MOV) { src = &insn->src(0); if (src->mod) WARN("OP_MOV with modifier encountered !\n"); } else { src = NULL; } } return false; }
Modifier *CMaxMesh::FindPhysiqueModifier(INode *pINode) { // get the object reference of the node Object *pObject; pObject = pINode->GetObjectRef(); if(pObject == 0) return 0; // loop through all derived objects while(pObject->SuperClassID() == GEN_DERIVOB_CLASS_ID) { IDerivedObject *pDerivedObject; pDerivedObject = static_cast<IDerivedObject *>(pObject); // loop through all modifiers int stackId; for(stackId = 0; stackId < pDerivedObject->NumModifiers(); stackId++) { // get the modifier Modifier *pModifier; pModifier = pDerivedObject->GetModifier(stackId); // check if we found the physique modifier if(pModifier->ClassID() == Class_ID(PHYSIQUE_CLASS_ID_A, PHYSIQUE_CLASS_ID_B)) return pModifier; } // continue with next derived object pObject = pDerivedObject->GetObjRef(); } return 0; }
ISkin* MaxExportPlugin::FindSkinModifier(INode* node) { Object* object = node->GetObjectRef(); if (!object) return 0; while (object->SuperClassID() == GEN_DERIVOB_CLASS_ID && object) { IDerivedObject* derivedObject = (IDerivedObject*)object; int modStackId = 0; while (modStackId < derivedObject->NumModifiers()) { Modifier* mod = derivedObject->GetModifier(modStackId); //file << "MODIFIER: " << std::to_wstring(mod->ClassID().PartA()) << " " << std::to_wstring(mod->ClassID().PartB()) << "\n"; if (mod->ClassID() == SKIN_CLASS_ID) { return (ISkin*)(mod->GetInterface(I_SKIN)); } modStackId++; } object = derivedObject->GetObjRef(); } return 0; }
// ================================================== FindPhysiqueModifier() // Find if a given node contains a Physique Modifier // DerivedObjectPtr requires you include "modstack.h" from the MAX SDK Modifier* FindPhysiqueModifier (INode* nodePtr) { // Get object from node. Abort if no object. Object* ObjectPtr = nodePtr->GetObjectRef(); if ( NULL == ObjectPtr) return NULL; // Is derived object ? if (ObjectPtr->SuperClassID() == GEN_DERIVOB_CLASS_ID){ // Yes -> Cast. IDerivedObject* DerivedObjectPtr = static_cast<IDerivedObject*>(ObjectPtr); // Iterate over all entries of the modifier stack. int ModStackIndex = 0; while (ModStackIndex < DerivedObjectPtr->NumModifiers()){ // Get current modifier. Modifier* ModifierPtr = DerivedObjectPtr->GetModifier(ModStackIndex); Class_ID clsid = ModifierPtr->ClassID(); // Is this Physique ? if (ModifierPtr->ClassID() == Class_ID(PHYSIQUE_CLASS_ID_A, PHYSIQUE_CLASS_ID_B)) { // Yes -> Exit. return ModifierPtr; } // Next modifier stack entry. ModStackIndex++; } } // Not found. return NULL; }
Modifier* PhyExportUtil::findPhysiqueModifier( INode* node ) { // Get object from node. Abort if no object. ::Object* obj = node->GetObjectRef(); if ( !obj ) return 0; // Is derived object ? while ( obj->SuperClassID() == GEN_DERIVOB_CLASS_ID && obj ) { // Yes -> Cast. IDerivedObject* derivedObj = static_cast<IDerivedObject*>( obj ); // Iterate over all entries of the modifier stack. for ( int modStackIndex = 0 ; modStackIndex < derivedObj->NumModifiers() ; ++modStackIndex ) { // Get current modifier. Modifier* modPtr = derivedObj->GetModifier( modStackIndex ); // Is this Physique ? if ( modPtr->ClassID() == Class_ID(PHYSIQUE_CLASS_ID_A, PHYSIQUE_CLASS_ID_B) ) { // Yes -> Exit. return modPtr; } } obj = derivedObj->GetObjRef(); } // Not found. return 0; }
//// FindSkinModifier /////////////////////////////////////////////////////// // Given an INode, gets the ISkin object of that node, or nil if there is // none. Taken from the Max4 SDK, ISkin.h ISkin* plMaxNodeBase::FindSkinModifier() { int modStackIndex; // Get object from node. Abort if no object. Object *pObj = GetObjectRef(); if( pObj == nil ) return nil; // Is derived object ? while( pObj->SuperClassID() == GEN_DERIVOB_CLASS_ID ) { IDerivedObject *pDerObj = (IDerivedObject *)pObj; // Iterate over all entries of the modifier stack. for( modStackIndex = 0; modStackIndex < pDerObj->NumModifiers(); modStackIndex++ ) { // Get current modifier. Modifier *mod = pDerObj->GetModifier( modStackIndex ); // Is this Skin ? if( mod->ClassID() == SKIN_CLASSID ) { ISkin* skin = (ISkin*)mod->GetInterface(I_SKIN); if( skin->GetNumBones() > 0 ) return skin; } } pObj = pDerObj->GetObjRef(); } // Not found. return nil; }
void accept_modifier( Modifier const& m ) { optionally_assign( m_value_handler, m, handler ); optionally_assign( m_value_interpreter, m, interpreter ); if( m.has( default_value ) ) { BOOST_RT_PARAM_VALIDATE_LOGIC( !m_value_generator, BOOST_RT_PARAM_LITERAL( "multiple value generators for parameter" ) ); T const& dv_ref = m[default_value]; m_value_generator = rt_cla_detail::const_generator<T>( dv_ref ); } if( m.has( default_refer_to ) ) { BOOST_RT_PARAM_VALIDATE_LOGIC( !m_value_generator, BOOST_RT_PARAM_LITERAL( "multiple value generators for parameter" ) ); cstring ref_id = m[default_refer_to]; m_value_generator = rt_cla_detail::ref_generator<T>( ref_id ); } if( m.has( assign_to ) ) { BOOST_RT_PARAM_VALIDATE_LOGIC( !m_value_handler, BOOST_RT_PARAM_LITERAL( "multiple value handlers for parameter" ) ); m_value_handler = rt_cla_detail::assigner<T>( m[assign_to] ); } }
Modifier* SGP_MaxInterface::FindModifier(INode *pINode, Class_ID id) { // get the object reference of the node Object *pObject; pObject = pINode->GetObjectRef(); if(pObject == NULL) return NULL; // loop through all derived objects while(pObject->SuperClassID() == GEN_DERIVOB_CLASS_ID) { IDerivedObject *pDerivedObject; pDerivedObject = static_cast<IDerivedObject *>(pObject); // loop through all modifiers int stackId; for(stackId = 0; stackId < pDerivedObject->NumModifiers(); stackId++) { // get the modifier Modifier *pModifier; pModifier = pDerivedObject->GetModifier(stackId); // check if we found the modifier if(pModifier->ClassID() == id) return pModifier; } // continue with next derived object pObject = pDerivedObject->GetObjRef(); } return NULL; }
/* ==================== GetModifier ==================== */ static Modifier* GetModifier( INode* i_node, Class_ID cid ) { // Get object from node. Abort if no object. Object* object = i_node->GetObjectRef(); if(!object) return NULL; // Is derived object ? if( object->SuperClassID() == GEN_DERIVOB_CLASS_ID ) { // Yes -> Cast. IDerivedObject* derived_object = static_cast< IDerivedObject* >( object ); // Iterate over all entries of the modifier stack. int modStackIndex = 0; while( modStackIndex < derived_object->NumModifiers() ) { // Get current modifier. Modifier* modifier = derived_object->GetModifier( modStackIndex ); // Is this ? if( modifier->ClassID() == cid ) { // Yes -> Exit. return modifier; } // Next modifier stack entry. modStackIndex++; } } // Not found. return NULL; }
void load( config_file_iterator cf_it, Modifier const& m ) { cstring vm = m.has( value_marker ) ? m[value_marker] : BOOST_RT_PARAM_CSTRING_LITERAL( "\"" ); cstring vd = m.has( value_delimeter ) ? m[value_delimeter] : BOOST_RT_PARAM_CSTRING_LITERAL( "= \t\n\r" ); cstring nd = m.has( namespace_delimeter ) ? m[namespace_delimeter] : BOOST_RT_PARAM_CSTRING_LITERAL( "::" ); load_impl( cf_it, vm, vd, nd ); }
TEST_F(CuckooTestFilled, DoesNotReplace) { std::unique_ptr<int> value(new int(8713)); crossbow::allocator alloc; Modifier m = table->modifier(); for (auto e : entries) { ASSERT_FALSE(m.insert(e, value.get(), false)) << "Replaced value for " << e; } }
uint64_t operator()(const Modifier& modifier) const { uint64_t h = static_cast<size_t>(modifier.getAttributeID()); h <<= 16; h |= static_cast<size_t>(modifier.getModifier()->getAttributeID()); h <<= 4; h |= static_cast<size_t>(modifier.getAssociation()); return h; }
//--------------------------------------------------------------- ISkinInterface* SkinController::getSkinInterface( INode *node ) { Modifier *m = getModifier(); if (m->ClassID() == SKIN_CLASSID) return new SkinInterface(m, node ); if (m->ClassID() == PHYSIQUE_CLASSID) return new PhysiqueSkinInterface(m, node); return 0; }
void addbend() { try { float radius = 10, height = 10, angle = 10; int segments = 20; // Create a new object using CreateInstance() Object *obj = (Object*)CreateInstance(GEOMOBJECT_CLASS_ID, Class_ID(CYLINDER_CLASS_ID, 0)); // Get ahold of the parameter block IParamArray *iCylParams = obj->GetParamBlock(); // Get the current animation time TimeValue time = GetCOREInterface()->GetTime(); // Set the value of radius, height and segments. iCylParams->SetValue(obj->GetParamBlockIndex(CYLINDER_RADIUS), time, radius); iCylParams->SetValue(obj->GetParamBlockIndex(CYLINDER_HEIGHT), time, height); iCylParams->SetValue(obj->GetParamBlockIndex(CYLINDER_SEGMENTS), time, segments); auto* ip = GetCOREInterface(); INode *node = ip->CreateObjectNode(obj); //Create a new object using CreateInstance() auto pINode = ip->GetSelNode(0); log(L"New node name is {0} : \n", pINode->GetName()); // Get the current animation time /*iCylParams->SetValue(obj->GetParamBlockIndex(CYLINDER_RADIUS), time, 10); iCylParams->SetValue(obj->GetParamBlockIndex(CYLINDER_HEIGHT), time, 20); iCylParams->SetValue(obj->GetParamBlockIndex(CYLINDER_SEGMENTS), time, 10);*/ // Create a bend modifier Modifier *bend = (Modifier*)ip->CreateInstance(OSM_CLASS_ID, Class_ID(BENDOSM_CLASS_ID, 0)); log(L"{}",bend->GetName().data()); // Set the bend angle IParamBlock2* ipBendBlock = ((Animatable*)bend)->GetParamBlock(0); //only one pblock2 //ipBendBlock->SetValue(BEND_ANGLE, time, 10); ipBendBlock->SetValue(BEND_ANGLE, time, angle); GetCOREInterface12()->AddModifier(*pINode, *bend); GetCOREInterface12()->AddModifier(*node, *bend); } catch (const std::exception& e) { /*e.what(); log("Exception: " + std::string(e.what()));*/ } }
// add m's modifiers where this dontcare void Modifier::add(const Modifier &i_m) { for (int i = 0; i < Type_end; ++ i) { if (isDontcare(static_cast<Modifier::Type>(i))) if (!i_m.isDontcare(static_cast<Modifier::Type>(i))) if (i_m.isPressed(static_cast<Modifier::Type>(i))) press(static_cast<Modifier::Type>(i)); else release(static_cast<Modifier::Type>(i)); } }
/* ==================== exportSkin ==================== */ bool G3DAExport::exportSkin(INode* i_node) { // get the modifier Modifier *modifier = getModifier(i_node,SKIN_CLASSID); if(modifier==NULL)return false; // get the skin interface ISkin* i_skin = (ISkin*)modifier->GetInterface(I_SKIN); if(i_skin == NULL) return false; // get the skin context data ISkinContextData* i_skin_context_data = i_skin->GetContextInterface(i_node); if(i_skin_context_data == NULL) return false; // process the bones std::vector<INode*>bones; int num_points = i_skin_context_data->GetNumPoints(); for (int i = 0; i < num_points; i++) { // get the number of bones that control this vertex int num_bones = i_skin_context_data->GetNumAssignedBones(i); for (int j = 0; j < num_bones; j++) { // get the assigned bone of the point INode* i_bone_node = i_skin->GetBone(i_skin_context_data->GetAssignedBone(i, j)); MAX_CHECK(i_bone_node != NULL); // add the bone node to the table std::vector<INode*>::iterator it = std::find(bones.begin(), bones.end(), i_bone_node); if(it==bones.end())bones.push_back(i_bone_node); } } // include all of the bone for (int i = 0; i < bones.size(); i++) { NODE *x = FindNode(mRoot, bones[i]) ; x->include = true; if(x->include) { NODE* parent = x->parent; while(parent) { parent->include = true; parent = parent->parent; } } } return true; }
bool AlembicCustomAttributesEx::defineCustomAttributes(INode* node, Abc::OCompoundProperty& compoundProp, const AbcA::MetaData& metadata, unsigned int animatedTs) { Modifier* pMod = FindModifier(node, (char*)this->modName.c_str()); if(!pMod){ return false; } ICustAttribContainer* cont = pMod->GetCustAttribContainer(); if(!cont){ return false; } for(int i=0; i<cont->GetNumCustAttribs(); i++) { CustAttrib* ca = cont->GetCustAttrib(i); std::string name = EC_MCHAR_to_UTF8( ca->GetName() ); pblock = ca->GetParamBlockByID(0); break; } if(!pblock){ return false; } for(int i=0, nNumParams = pblock->NumParams(); i<nNumParams; i++){ ParamID id = pblock->IndextoID(i); MSTR name = pblock->GetLocalName(id, 0); std::stringstream propName; propName<<EC_MSTR_to_UTF8(name); ParamType2 type = pblock->GetParameterType(id); if(type == TYPE_STRING){ customProps[propName.str()] = new Abc::OStringProperty(compoundProp, propName.str().c_str(), metadata, animatedTs ); } else if(type == TYPE_FLOAT){ customProps[propName.str()] = new Abc::OFloatProperty(compoundProp, propName.str().c_str(), metadata, animatedTs ); } else if(type == TYPE_INT){ customProps[propName.str()] = new Abc::OInt32Property(compoundProp, propName.str().c_str(), metadata, animatedTs ); } } return true; }
void accept_modifier( Modifier const& m ) { if( m.has( optional_m ) ) p_optional.value = true; if( m.has( required_m ) ) p_optional.value = false; if( m.has( multiplicable_m ) ) p_multiplicable.value = true; if( m.has( optional_value_m ) ) p_optional_value.value = true; nfp::optionally_assign( p_description.value, m, description ); }
bool TargetNVC0::isModSupported(const Instruction *insn, int s, Modifier mod) const { if (!isFloatType(insn->dType)) { switch (insn->op) { case OP_ABS: case OP_NEG: case OP_CVT: case OP_CEIL: case OP_FLOOR: case OP_TRUNC: case OP_AND: case OP_OR: case OP_XOR: break; case OP_ADD: if (mod.abs()) return false; if (insn->src(s ? 0 : 1).mod.neg()) return false; break; case OP_SUB: if (s == 0) return insn->src(1).mod.neg() ? false : true; break; default: return false; } } if (s > 3) return false; return (mod & Modifier(opInfo[insn->op].srcMods[s])) == mod; }
PaintDefromModData *PaintDeformTest::GetPMD(INode *pNode) { ModContext *mc = NULL; Object* pObj = pNode->GetObjectRef(); if (!pObj) return NULL; while (pObj->SuperClassID() == GEN_DERIVOB_CLASS_ID && mc == NULL) { IDerivedObject* pDerObj = (IDerivedObject *)(pObj); int Idx = 0; while (Idx < pDerObj->NumModifiers()) { // Get the modifier. Modifier* mod = pDerObj->GetModifier(Idx); if (mod->ClassID() == PAINTDEFORMTEST_CLASS_ID) { // is this the correct Physique Modifier based on index? PaintDeformTest *pmod = (PaintDeformTest*)mod; if (pmod == this) { mc = pDerObj->GetModContext(Idx); break; } } Idx++; } pObj = pDerObj->GetObjRef(); } if(!mc) return NULL; if ( !mc->localData ) return NULL; PaintDefromModData *bmd = (PaintDefromModData *) mc->localData; return bmd; }
TEST_F(CuckooTestFilled, TestResize) { crossbow::allocator alloc; int oVal = 2; Modifier m = table->modifier(); size_t oldCapacity = m.capacity(); decltype(entries) newEntries; std::mt19937 rnd(10); std::uniform_int_distribution<uint64_t> dist; auto toAdd = m.capacity() - m.size(); for (decltype(toAdd) i = 0; i <= toAdd; ++i) { auto nVal = dist(rnd); if (entries.find(nVal) != entries.end()) { --i; continue; } ASSERT_TRUE(m.insert(nVal, &oVal, false)); } ASSERT_NE(oldCapacity, m.capacity()); auto oldTable = table; table = m.done(); crossbow::allocator::destroy_now(oldTable); auto& t = *table; for (auto e : entries) { auto ptr = reinterpret_cast<int*>(t.get(e)); ASSERT_EQ(ptr, &value); ASSERT_EQ(*ptr, value); } for (auto e : newEntries) { auto ptr = reinterpret_cast<int*>(t.get(e)); ASSERT_EQ(ptr, &oVal); ASSERT_EQ(*ptr, oVal); } }
icap::Response * RequestHandler::process_modify( icap::Request * request ) throw() { icap::Response * response = NULL; Modifier * modifier; int i = 0; // logger Logger &logger = Logger::instance(); /* * Loop through loaded modifier modules and grab responses * * We will only return the response from the last module * unless a icap::ResponseHeader::OK is received */ for ( i = 0 ; i < _handlers_count; i++ ) { // sanity check if ( _handlers[i].name == "" ) { logger.info( "[req] modifier not loaded, not trying to get a response" ); continue; } // grab the response from modifier logger.debug( std::string( "[req] getting modify response from modifier: " ).append( _handlers[i].name ) ); modifier = _handlers[i].symbols.create(); response = modifier->modify( request ); // cleanup logger.debug( std::string( "[req] cleaning up modifier: " ).append( _handlers[i].name ) ); _handlers[i].symbols.destroy( modifier ); // status 200 OK means content modified if ( response->header()->status() == icap::ResponseHeader::OK ) { logger.debug( "[req] OK response received, not getting responses from other modifiers" ); break; } } return response; }
ISkin* CExporter::getISkinPtr(Object* object) { assert(object != NULL); while (GEN_DERIVOB_CLASS_ID == object->SuperClassID()) { IDerivedObject* pDerObj = static_cast<IDerivedObject*>(object); for (int i = 0; i < pDerObj->NumModifiers(); ++i) { Modifier* mod = pDerObj->GetModifier(i); if (SKIN_CLASSID == mod->ClassID()) { return (ISkin*)(mod->GetInterface(I_SKIN)); } } object = pDerObj->GetObjRef(); } return NULL; }
bool RBExport::ProcessSkin( INode* node ) { m_pSkin = NULL; m_pSkinData = NULL; m_pPhysique = NULL; Modifier* pMod = NULL; // check for 'Skin' modifier pMod = FindModifier( node, SKIN_CLASSID ); if (pMod) { m_pSkin = (ISkin*) pMod->GetInterface( I_SKIN ); if (!m_pSkin) return false; m_pSkinData = m_pSkin->GetContextInterface( node ); // build bone reindexing table for the skin int nBones = m_pSkin->GetNumBones(); for (int i = 0; i < nBones; i++) { INode* pBoneNode = m_pSkin->GetBone( i ); ExpNode* pExportedBone = GetExportedNode( pBoneNode ); m_pCurExpNode->m_BoneIdx.push_back( pExportedBone->m_Index ); } return true; } // check for physique modifier pMod = FindModifier( node, Class_ID( PHYSIQUE_CLASS_ID_A, PHYSIQUE_CLASS_ID_B ) ); if (pMod) { IPhysiqueExport* iPExport = (IPhysiqueExport*)pMod->GetInterface( I_PHYINTERFACE ); if (!iPExport) return false; m_pPhysique = (IPhyContextExport*) iPExport->GetContextInterface( node ); if (!m_pPhysique) return false; // convert to rigid with blending m_pPhysique->ConvertToRigid ( TRUE ); m_pPhysique->AllowBlending ( TRUE ); return true; } return false; } // RBExport::ProcessSkin
Modifier *FindSkinModifier (INode *node) { Object* ObjectPtr = node->GetObjectRef(); if (!ObjectPtr) return NULL; while (ObjectPtr->SuperClassID() == GEN_DERIVOB_CLASS_ID && ObjectPtr) { IDerivedObject *DerivedObjectPtr = (IDerivedObject *)(ObjectPtr); int ModStackIndex = 0; while (ModStackIndex < DerivedObjectPtr->NumModifiers()) { Modifier* ModifierPtr = DerivedObjectPtr->GetModifier(ModStackIndex); if (ModifierPtr->ClassID() == SKIN_CLASSID) return ModifierPtr; ModStackIndex++; } ObjectPtr = DerivedObjectPtr->GetObjRef(); } return NULL; }
//---------------------------------------------------------------------------- void SceneBuilder::ApplyModifiers() { // 遍历节点使用收集的修改器,当前唯一支持的修改器是skin。 std::vector<ModifierInfo*>::iterator itI = mModifierList.begin(); for (; itI!=mModifierList.end(); itI++) { ModifierInfo *info = *itI; std::vector<Modifier*>::iterator itJ = info->Modifiers.begin(); for (; itJ!=info->Modifiers.end(); itJ++) { Modifier *modifier = *itJ; Class_ID id = modifier->ClassID(); if (id == SKIN_CLASSID) { ProcessSkin(info->Node, modifier); } } } }
/** * @brief * Destructor */ Widget::~Widget() { // Delete child widgets /* // Do not, since all widgets are automatically added to the destroy-list after an OnDestroy-message List<Widget*> lstChildren = m_lstChildren; for (uint32 i=0; i<lstChildren.GetNumOfElements(); i++) { delete lstChildren[i]; } */ // Destroy modifiers for (uint32 i=0; i<m_lstModifiers.GetNumOfElements(); i++) { // Detach and delete modifier Modifier *pModifier = m_lstModifiers[i]; pModifier->Detach(); delete pModifier; } // Delete widget implementation if (m_pWidgetImpl) delete m_pWidgetImpl; }
int32_t Padder::padAndApply(const Modifier &mod1, const Modifier &mod2, NumberStringBuilder &string, int32_t leftIndex, int32_t rightIndex, UErrorCode &status) const { int32_t modLength = mod1.getCodePointCount(status) + mod2.getCodePointCount(status); int32_t requiredPadding = fWidth - modLength - string.codePointCount(); U_ASSERT(leftIndex == 0 && rightIndex == string.length()); // fix the previous line to remove this assertion int length = 0; if (requiredPadding <= 0) { // Padding is not required. length += mod1.apply(string, leftIndex, rightIndex, status); length += mod2.apply(string, leftIndex, rightIndex + length, status); return length; } PadPosition position = fUnion.padding.fPosition; UChar32 paddingCp = fUnion.padding.fCp; if (position == UNUM_PAD_AFTER_PREFIX) { length += addPaddingHelper(paddingCp, requiredPadding, string, leftIndex, status); } else if (position == UNUM_PAD_BEFORE_SUFFIX) { length += addPaddingHelper(paddingCp, requiredPadding, string, rightIndex + length, status); } length += mod1.apply(string, leftIndex, rightIndex + length, status); length += mod2.apply(string, leftIndex, rightIndex + length, status); if (position == UNUM_PAD_BEFORE_PREFIX) { length += addPaddingHelper(paddingCp, requiredPadding, string, leftIndex, status); } else if (position == UNUM_PAD_AFTER_SUFFIX) { length += addPaddingHelper(paddingCp, requiredPadding, string, rightIndex + length, status); } return length; }