コード例 #1
0
void RemoteObjectGenerator::checkForEventMembersImpl(const Poco::CppParser::Struct* pStruct)
{
	Poco::CppParser::NameSpace::SymbolTable tbl;
	pStruct->variables(tbl);
	Poco::CppParser::NameSpace::SymbolTable::const_iterator it = tbl.begin();
	Poco::CppParser::NameSpace::SymbolTable::const_iterator itEnd = tbl.end();
	for (; it != itEnd; ++it)
	{
		Poco::CppParser::Variable* pVar = static_cast<Poco::CppParser::Variable*>(it->second);
		const std::string& varType = pVar->declType();
		if (pVar->getAccess() == Poco::CppParser::Variable::ACC_PUBLIC && !(pVar->flags() & Poco::CppParser::Variable::VAR_STATIC))
		{
			if (varType.find("Poco::BasicEvent") == 0 || varType.find("Poco::FIFOEvent") == 0)
			{
				_hasEvents = true;
				_events.push_back(pVar->name());
				_cppGen.addSrcIncludeFile("Poco/RemotingNG/ORB.h");
				_cppGen.addSrcIncludeFile("Poco/Delegate.h");
				// generate a serializer method for that member too
				// call methodStart(const Poco::CppParser::Function* pFuncOld, const CodeGenerator::Properties& methodProperties)
				// convert the basicevent to a private function
				std::string funcDecl("void ");
				std::string fctName = generateEventFunctionName(pVar->name());
				funcDecl.append(fctName);
				std::vector<std::string> templTypes = GenUtility::getResolvedInnerTemplateTypes(pStruct, varType);
				if (templTypes.size() != 1)
					throw Poco::InvalidArgumentException("Illegal remote event param: " + pVar->fullName());
				std::string paramDecl = templTypes[0];
				if (paramDecl != "void")
				{
					paramDecl.append("& data");
				}
				Poco::CppParser::Function* pFunc = new Poco::CppParser::Function(funcDecl, _pStruct);
				pFunc->setAccess(Poco::CppParser::Symbol::ACC_PROTECTED);
				if (paramDecl != "void")
				{
					Poco::CppParser::Parameter* pParam = new Poco::CppParser::Parameter(paramDecl, 0);
					pFunc->addParameter(pParam);
				}
			}
		}
	}
}
コード例 #2
0
void XSDGenerator::deepCopyMembers(const Poco::CppParser::Struct* pIn, Poco::CppParser::Struct* pOut)
{
	// deep copy all variables and functions, exluding constructor/destructor
	Poco::CppParser::Struct::BaseIterator itB = pIn->baseBegin();
	Poco::CppParser::Struct::BaseIterator itBEnd = pIn->baseEnd();
	for (; itB!= itBEnd; ++itB)
	{
		if (itB->pClass)
			deepCopyMembers(itB->pClass, pOut);
	}
	// handle members
	Poco::CppParser::NameSpace::SymbolTable members;
	pIn->variables(members);
	Poco::CppParser::NameSpace::SymbolTable::const_iterator it = members.begin();
	Poco::CppParser::NameSpace::SymbolTable::const_iterator itEnd = members.end();
	for (; it != itEnd; ++it)
	{
		Poco::CppParser::Variable* pVar = static_cast<Poco::CppParser::Variable*>(it->second);
		Poco::CppParser::Variable* pCpyVar = new Poco::CppParser::Variable(pVar->declaration(), pOut);
		pCpyVar->setAccess(pVar->getAccess());
		pCpyVar->setAttributes(pVar->getAttributes());
	}
	// handle methods
	members.clear();
	Poco::CppParser::Struct::Functions fcts;
	pIn->methods(Poco::CppParser::Symbol::ACC_PUBLIC, fcts);
	Poco::CppParser::Struct::Functions::const_iterator itt = fcts.begin();
	Poco::CppParser::Struct::Functions::const_iterator ittEnd = fcts.end();
	for (; itt != ittEnd; ++itt)
	{
		Poco::CppParser::Function* pFct = static_cast<Poco::CppParser::Function*>(*itt);
		if (!pFct->isConstructor() && ! pFct->isDestructor())
		{
			Poco::CppParser::Function* pCpyFct = new Poco::CppParser::Function(pFct->declaration(), pOut);
			pCpyFct->setAccess (pFct->getAccess());
			addDocumentation(pFct, pCpyFct);
			pCpyFct->setAttributes(pFct->getAttributes());
			if (pFct->isConst())
				pCpyFct->makeConst();

			Poco::CppParser::Function::Iterator itF = pFct->begin();
			Poco::CppParser::Function::Iterator itFEnd = pFct->end();

			for (; itF != itFEnd; ++itF)
			{
				std::string decl = Poco::CodeGeneration::Utility::resolveParamDecl(pIn, *itF);
				if ((*itF)->hasDefaultValue())
				{
					decl.append(" = ");
					decl.append(Poco::CodeGeneration::Utility::resolveType(_pStructIn, (*itF)->declType()));
					decl.append("(");
					decl.append((*itF)->defaultValue());
					decl.append(")");
				}
				
				Poco::CppParser::Parameter* pParam = new Poco::CppParser::Parameter(decl, pCpyFct);
				
				pCpyFct->addParameter(pParam);
			}
		}
			
	}
}