void synthesizeConstructors(Program& program)
{
    FindAllTypes findAllTypes;
    findAllTypes.checkErrorAndVisit(program);
    auto m_unnamedTypes = findAllTypes.takeUnnamedTypes();
    auto m_namedTypes = findAllTypes.takeNamedTypes();

    bool isOperator = true;

    for (auto& unnamedType : m_unnamedTypes) {
        AST::VariableDeclaration variableDeclaration(Lexer::Token(unnamedType.get().origin()), AST::Qualifiers(), { unnamedType.get().clone() }, String(), WTF::nullopt, WTF::nullopt);
        AST::VariableDeclarations parameters;
        parameters.append(WTFMove(variableDeclaration));
        AST::NativeFunctionDeclaration copyConstructor(AST::FunctionDeclaration(Lexer::Token(unnamedType.get().origin()), AST::AttributeBlock(), WTF::nullopt, unnamedType.get().clone(), "operator cast"_str, WTFMove(parameters), WTF::nullopt, isOperator));
        program.append(WTFMove(copyConstructor));

        AST::NativeFunctionDeclaration defaultConstructor(AST::FunctionDeclaration(Lexer::Token(unnamedType.get().origin()), AST::AttributeBlock(), WTF::nullopt, unnamedType.get().clone(), "operator cast"_str, AST::VariableDeclarations(), WTF::nullopt, isOperator));
        program.append(WTFMove(defaultConstructor));
    }

    for (auto& namedType : m_namedTypes) {
        AST::VariableDeclaration variableDeclaration(Lexer::Token(namedType.get().origin()), AST::Qualifiers(), { AST::TypeReference::wrap(Lexer::Token(namedType.get().origin()), namedType.get()) }, String(), WTF::nullopt, WTF::nullopt);
        AST::VariableDeclarations parameters;
        parameters.append(WTFMove(variableDeclaration));
        AST::NativeFunctionDeclaration copyConstructor(AST::FunctionDeclaration(Lexer::Token(namedType.get().origin()), AST::AttributeBlock(), WTF::nullopt, AST::TypeReference::wrap(Lexer::Token(namedType.get().origin()), namedType.get()), "operator cast"_str, WTFMove(parameters), WTF::nullopt, isOperator));
        program.append(WTFMove(copyConstructor));

        AST::NativeFunctionDeclaration defaultConstructor(AST::FunctionDeclaration(Lexer::Token(namedType.get().origin()), AST::AttributeBlock(), WTF::nullopt, AST::TypeReference::wrap(Lexer::Token(namedType.get().origin()), namedType.get()), "operator cast"_str, AST::VariableDeclarations(), WTF::nullopt, isOperator));
        program.append(WTFMove(defaultConstructor));
    }
}
void CXXClass::addMissingConstructor()
{
	for ( auto m : _methods )
	{
		if ( m.isConstructor() )
			return;
	}
	
	// no constructor, synthesize one
	CXXMethod defaultConstructor( CXXMethod::type_t::kNormal, CXXMethod::access_t::kPublic,
								 false,
								 name(),
								 clang::QualType() );
	
	addMethod( defaultConstructor );
}
示例#3
0
NetworkNode::NetworkNode(int number) {
	defaultConstructor();

	_number = number;
}
示例#4
0
NetworkNode::NetworkNode() {
	defaultConstructor();
}
TEST_F(OrderedArrayList_test, DefaultConstructor) {
   defaultConstructor(OrderedArrayList::TYPE_INFO);
}
示例#6
0
文件: Mesh.cpp 项目: cybersphinx/WMIT
Mesh::Mesh()
{
    defaultConstructor();
}
示例#7
0
文件: Mesh.cpp 项目: cybersphinx/WMIT
Mesh::Mesh(const Pie3Level& p3)
{
    std::vector<Pie3Polygon>::const_iterator itL;

    typedef std::set<WZMPoint, compareWZMPoint_less_wEps> t_tupleSet;
    t_tupleSet tupleSet;
    std::pair<t_tupleSet::iterator, bool> inResult;

    std::vector<unsigned> mapping;
    std::vector<unsigned>::iterator itMap;

    IndexedTri iTri;
    WZMVertex tmpNrm;

    defaultConstructor();

    /*
     *	Try to prevent duplicate vertices
     *	(remember, different UV's, or animations,
     *	 will cause unavoidable duplication)
     *	so that our transformed vertex cache isn't
     *	completely useless.
     */

    // For each pie3 polygon
    for (itL = p3.m_polygons.begin(); itL != p3.m_polygons.end(); ++itL)
    {
        // pie2 integer-type problem?
        if (itL->getIndex(0) == itL->getIndex(1) || itL->getIndex(1) == itL->getIndex(2) || itL->getIndex(0) == itL->getIndex(2))
        {
            continue;
        }
        if (itL->m_texCoords[0] == itL->m_texCoords[1] || itL->m_texCoords[1] == itL->m_texCoords[2] || itL->m_texCoords[0] == itL->m_texCoords[2])
        {
            continue;
        }

        tmpNrm = normalizeVector(WZMVertex(WZMVertex(p3.m_points[itL->getIndex(1)]) - WZMVertex(p3.m_points[itL->getIndex(0)]))
                                 .crossProduct(WZMVertex(p3.m_points[itL->getIndex(2)]) - WZMVertex(p3.m_points[itL->getIndex(0)])));;

        // For all 3 vertices of the triangle
        for (int i = 0; i < 3; ++i)
        {
            inResult = tupleSet.insert(WZMPoint(p3.m_points[itL->getIndex(i)], itL->getUV(i, 0), tmpNrm));

            if (!inResult.second)
            {
                iTri.operator[](i) = mapping[std::distance(tupleSet.begin(), inResult.first)];
            }
            else
            {
                itMap = mapping.begin();
                std::advance(itMap, std::distance(tupleSet.begin(), inResult.first));
                mapping.insert(itMap, vertices());
                iTri.operator[](i) = vertices();
                addPoint(*inResult.first);
            }
        }
        addIndices(iTri);
    }

    std::list<Pie3Connector>::const_iterator itC;

    // For each pie3 connector
    for (itC = p3.m_connectors.begin(); itC != p3.m_connectors.end(); ++itC)
    {
        addConnector(WZMConnector(itC->pos.operator[](0),
                                  itC->pos.operator[](1),
                                  itC->pos.operator[](2)));
    }

    finishImport();
    recalculateBoundData();
}