当前位置: 首页>>代码示例>>C++>>正文


C++ EventsCodeGenerator::AddIncludeFile方法代码示例

本文整理汇总了C++中gd::EventsCodeGenerator::AddIncludeFile方法的典型用法代码示例。如果您正苦于以下问题:C++ EventsCodeGenerator::AddIncludeFile方法的具体用法?C++ EventsCodeGenerator::AddIncludeFile怎么用?C++ EventsCodeGenerator::AddIncludeFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gd::EventsCodeGenerator的用法示例。


在下文中一共展示了EventsCodeGenerator::AddIncludeFile方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GenerateCode

                virtual std::string GenerateCode(gd::Instruction & instruction, gd::EventsCodeGenerator & codeGenerator, gd::EventsCodeGenerationContext & context)
                {
                    codeGenerator.AddIncludeFile("TimedEvent/TimedEventTools.h");

                    for (unsigned int i = 0;i<TimedEvent::codeGenerationCurrentParents.size();++i)
                    {
                        if ( TimedEvent::codeGenerationCurrentParents[i] == NULL )
                        {
                            std::cout << "WARNING : NULL timed event in codeGenerationCurrentParents";
                            continue;
                        }

                        if (TimedEvent::codeGenerationCurrentParents[i]->GetName() == instruction.GetParameter(0).GetPlainString())
                        {
                            TimedEvent & timedEvent = *TimedEvent::codeGenerationCurrentParents[i];

                            std::string code;
                            {
                                std::string codeName = !timedEvent.GetName().empty() ? "GDNamedTimedEvent_"+codeGenerator.ConvertToString(timedEvent.GetName()) : "GDTimedEvent_"+ToString(&timedEvent);
                                code += "GDpriv::TimedEvents::Reset(*runtimeContext->scene, \""+codeName+"\");\n";
                            }
                            for (unsigned int j = 0;j<timedEvent.codeGenerationChildren.size();++j)
                            {
                                std::string codeName = !timedEvent.codeGenerationChildren[j]->GetName().empty() ? "GDNamedTimedEvent_"+codeGenerator.ConvertToString(timedEvent.codeGenerationChildren[j]->GetName()) : "GDTimedEvent_"+ToString(timedEvent.codeGenerationChildren[j]);
                                code += "GDpriv::TimedEvents::Reset(*runtimeContext->scene, \""+codeName+"\");\n";
                            }
                            return code;
                        }
                    }

                    return "";
                };
开发者ID:cubemoon,项目名称:GD,代码行数:32,代码来源:Extension.cpp

示例2: callbacks

                virtual std::string GenerateCode(const std::vector<gd::Expression> & parameters, gd::EventsCodeGenerator & codeGenerator, gd::EventsCodeGenerationContext & context)
                {
                    codeGenerator.AddGlobalDeclaration(FunctionEvent::globalDeclaration);
                    codeGenerator.AddIncludeFile("Function/FunctionTools.h");
                    const gd::Project & game = codeGenerator.GetProject();
                    const gd::Layout & scene = codeGenerator.GetLayout();

                    //Generate code for evaluating index
                    std::string expression;
                    gd::CallbacksForGeneratingExpressionCode callbacks(expression, codeGenerator, context);
                    gd::ExpressionParser parser(parameters[0].GetPlainString());
                    if (!parser.ParseMathExpression(codeGenerator.GetPlatform(), game, scene, callbacks) || expression.empty()) expression = "0";

                    std::string code;

                    code += "GDpriv::FunctionTools::GetSafelyStringFromVector(currentFunctionParameters, "+expression+")";

                    return code;
                };
开发者ID:cubemoon,项目名称:GD,代码行数:19,代码来源:Extension.cpp

示例3: GenerateEventCode

gd::String ProfileEvent::GenerateEventCode(gd::EventsCodeGenerator & codeGenerator, gd::EventsCodeGenerationContext & parentContext)
{
    const gd::Layout & scene = codeGenerator.GetLayout();
    codeGenerator.AddIncludeFile("GDCpp/BuiltinExtensions/ProfileTools.h");

    ProfileLink profileLink;
    profileLink.originalEvent = originalEvent;
    std::cout << scene.GetProfiler() << std::endl;
    if ( scene.GetProfiler() ) //Should always be not NULL
    {
        scene.GetProfiler()->profileEventsInformation.push_back(profileLink);
        index = scene.GetProfiler()->profileEventsInformation.size()-1;
    }
    gd::String code;

    if ( previousProfileEvent )
        code += "EndProfileTimer(*runtimeContext->scene, "+gd::String::From(previousProfileEvent->index)+");\n";

    code += "StartProfileTimer(*runtimeContext->scene, "+gd::String::From(index)+");\n";

    return code;
}
开发者ID:sanyaade-teachings,项目名称:GD,代码行数:22,代码来源:ProfileEvent.cpp

示例4: code

std::string Array3DEvent::CodeGenerator::Generate(gd::BaseEvent & event_, gd::EventsCodeGenerator & codeGenerator, gd::EventsCodeGenerationContext &context)
{
    arr::threeDim::Array3DEvent &event = dynamic_cast<arr::threeDim::Array3DEvent&>(event_);

            // Adding needed includes
            codeGenerator.AddIncludeFile("stack");
            codeGenerator.AddIncludeFile("Array/ArrayValue.h");
            codeGenerator.AddIncludeFile("Array/Array3D.h");
            codeGenerator.AddIncludeFile("Array/ArrayTools.h");

            //Adding the main code of the event
            std::string code("// 3D-Array Iterate Event\n");

            std::string arrayNameExpr;
            gd::CallbacksForGeneratingExpressionCode callbacks(arrayNameExpr, codeGenerator, context);
            gd::ExpressionParser parser(event.GetArrayName());
            parser.ParseStringExpression(codeGenerator.GetPlatform(), codeGenerator.GetProject(), codeGenerator.GetLayout(), callbacks);
            if (arrayNameExpr.empty()) arrayNameExpr = "\"\""; //If generation failed, we make sure output code is not empty.

            code += "arr::Array3D &currentArray = arr::ArrayManager::GetInstance()->GetArray3D(runtimeContext->scene->game, " + arrayNameExpr + ");\n";
            code += "for(unsigned int x = 0; x < currentArray.GetSize(1); x++)\n";
            code += "{\n";
            {
                code += "for(unsigned int y = 0; y < currentArray.GetSize(2); y++)\n";
                code += "{\n";
                {
                    code += "for(unsigned int z = 0; z < currentArray.GetSize(3); z++)\n";
                    code += "{\n";
                    {

                        code += "arr::ArrayManager::GetInstance()->GetArray3DEventInfo(runtimeContext->scene->game).PushNewEventInfo(x, y, z, currentArray.GetValue(x, y, z));";

                        // Generating condition/action/sub-event //
                        code += codeGenerator.GenerateConditionsListCode(event.GetConditions(), context);

                        std::string ifPredicat;
                        for (unsigned int i = 0;i<event.GetConditions().size();++i)
                        {
                            if (i!=0)
                                ifPredicat += " && ";
                            ifPredicat += "condition"+ToString(i)+"IsTrue";
                        }

                        if ( !ifPredicat.empty() ) code += "if (" +ifPredicat+ ")\n";

                        code += "{\n";
                        code += codeGenerator.GenerateActionsListCode(event.GetActions(), context);

                        if ( event.HasSubEvents() )
                        {
                            code += "\n{\n";
                            code += codeGenerator.GenerateEventsListCode(event.GetSubEvents(), context);
                            code += "}\n";
                        }

                        code += "}\n";
                        ///////////////////////////////////////////

                        code += "arr::ArrayManager::GetInstance()->GetArray3DEventInfo(runtimeContext->scene->game).PopEventInfo();";
                    }
                    code += "}\n";
                }
                code += "}\n";
            }
            code += "}\n";


            return code;
}
开发者ID:victorlevasseur,项目名称:GD-Array-Extension,代码行数:69,代码来源:Array3DEvent.cpp


注:本文中的gd::EventsCodeGenerator::AddIncludeFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。