bool BaseBlock::inspectBlock(Parser& parser, Parser::name_stack_t name_stack) const { // named param is one like LLView::Params::follows // unnamed param is like LLView::Params::rect - implicit const BlockDescriptor& block_data = mostDerivedBlockDescriptor(); for (BlockDescriptor::param_list_t::const_iterator it = block_data.mUnnamedParams.begin(); it != block_data.mUnnamedParams.end(); ++it) { param_handle_t param_handle = (*it)->mParamHandle; const Param* param = getParamFromHandle(param_handle); ParamDescriptor::inspect_func_t inspect_func = (*it)->mInspectFunc; if (inspect_func) { (*it)->mGeneration = parser.newParseGeneration(); name_stack.push_back(std::make_pair("", (*it)->mGeneration)); inspect_func(*param, parser, name_stack, (*it)->mMinCount, (*it)->mMaxCount); name_stack.pop_back(); } } for(BlockDescriptor::param_map_t::const_iterator it = block_data.mNamedParams.begin(); it != block_data.mNamedParams.end(); ++it) { param_handle_t param_handle = it->second->mParamHandle; const Param* param = getParamFromHandle(param_handle); ParamDescriptor::inspect_func_t inspect_func = it->second->mInspectFunc; if (inspect_func) { // Ensure this param has not already been inspected bool duplicate = false; for (BlockDescriptor::param_list_t::const_iterator it2 = block_data.mUnnamedParams.begin(); it2 != block_data.mUnnamedParams.end(); ++it2) { if (param_handle == (*it2)->mParamHandle) { duplicate = true; break; } } if (!duplicate) { it->second->mGeneration = parser.newParseGeneration(); } name_stack.push_back(std::make_pair(it->first, it->second->mGeneration)); inspect_func(*param, parser, name_stack, it->second->mMinCount, it->second->mMaxCount); name_stack.pop_back(); } } return true; }
bool BaseBlock::serializeBlock(Parser& parser, Parser::name_stack_t name_stack, const LLInitParam::BaseBlock* diff_block) const { // named param is one like LLView::Params::follows // unnamed param is like LLView::Params::rect - implicit const BlockDescriptor& block_data = mostDerivedBlockDescriptor(); for (BlockDescriptor::param_list_t::const_iterator it = block_data.mUnnamedParams.begin(); it != block_data.mUnnamedParams.end(); ++it) { param_handle_t param_handle = (*it)->mParamHandle; const Param* param = getParamFromHandle(param_handle); ParamDescriptor::serialize_func_t serialize_func = (*it)->mSerializeFunc; if (serialize_func) { const Param* diff_param = diff_block ? diff_block->getParamFromHandle(param_handle) : NULL; // each param descriptor remembers its serial number // so we can inspect the same param under different names // and see that it has the same number (*it)->mGeneration = parser.newParseGeneration(); name_stack.push_back(std::make_pair("", (*it)->mGeneration)); serialize_func(*param, parser, name_stack, diff_param); name_stack.pop_back(); } } for(BlockDescriptor::param_map_t::const_iterator it = block_data.mNamedParams.begin(); it != block_data.mNamedParams.end(); ++it) { param_handle_t param_handle = it->second->mParamHandle; const Param* param = getParamFromHandle(param_handle); ParamDescriptor::serialize_func_t serialize_func = it->second->mSerializeFunc; if (serialize_func && param->anyProvided()) { // Ensure this param has not already been serialized // Prevents <rect> from being serialized as its own tag. bool duplicate = false; for (BlockDescriptor::param_list_t::const_iterator it2 = block_data.mUnnamedParams.begin(); it2 != block_data.mUnnamedParams.end(); ++it2) { if (param_handle == (*it2)->mParamHandle) { duplicate = true; break; } } //FIXME: for now, don't attempt to serialize values under synonyms, as current parsers // don't know how to detect them if (duplicate) { continue; } if (!duplicate) { it->second->mGeneration = parser.newParseGeneration(); } name_stack.push_back(std::make_pair(it->first, it->second->mGeneration)); const Param* diff_param = diff_block ? diff_block->getParamFromHandle(param_handle) : NULL; serialize_func(*param, parser, name_stack, diff_param); name_stack.pop_back(); } } return true; }