本文整理汇总了C++中gd::EventsCodeGenerator::ConvertToString方法的典型用法代码示例。如果您正苦于以下问题:C++ EventsCodeGenerator::ConvertToString方法的具体用法?C++ EventsCodeGenerator::ConvertToString怎么用?C++ EventsCodeGenerator::ConvertToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gd::EventsCodeGenerator
的用法示例。
在下文中一共展示了EventsCodeGenerator::ConvertToString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GenerateCode
virtual std::string GenerateCode(gd::Instruction & instruction, gd::EventsCodeGenerator & codeGenerator, gd::EventsCodeGenerationContext & context)
{
codeGenerator.AddIncludeFile("TimedEvent/TimedEventTools.h");
std::string codeName = "GDNamedTimedEvent_"+codeGenerator.ConvertToString(instruction.GetParameter(1).GetPlainString());
return "GDpriv::TimedEvents::Reset(*runtimeContext->scene, \""+codeName+"\");\n";
return "";
};
示例2: callbacks
virtual std::string GenerateCode(gd::Instruction & instruction, gd::EventsCodeGenerator & codeGenerator, gd::EventsCodeGenerationContext & context)
{
codeGenerator.AddGlobalDeclaration(FunctionEvent::globalDeclaration);
std::string functionName = instruction.GetParameter(0).GetPlainString();
const gd::Project & project = codeGenerator.GetProject();
const gd::Layout & scene = codeGenerator.GetLayout();
const FunctionEvent * functionEvent = FunctionEvent::SearchForFunctionInEvents(scene.GetEvents(), functionName);
if ( !functionEvent )
{
std::cout << "Function \""+functionName+"\" not found!" << std::endl;
return "//Function \""+functionName+"\" not found.\n";
}
std::string code;
//Generate code for objects passed as arguments
std::string objectsAsArgumentCode;
{
objectsAsArgumentCode += "runtimeContext->ClearObjectListsMap()";
std::vector<std::string> realObjects = codeGenerator.ExpandObjectsName(functionEvent->GetObjectsPassedAsArgument(), context);
for (unsigned int i = 0;i<realObjects.size();++i)
{
context.EmptyObjectsListNeeded(realObjects[i]);
objectsAsArgumentCode += ".AddObjectListToMap(\""+codeGenerator.ConvertToString(realObjects[i])+"\", "+ManObjListName(realObjects[i])+")";
}
objectsAsArgumentCode += ".ReturnObjectListsMap()";
}
//Generate code for evaluating parameters
code += "std::vector<std::string> functionParameters;\n";
for (unsigned int i = 1;i<8;++i)
{
std::string parameterCode;
gd::CallbacksForGeneratingExpressionCode callbacks(parameterCode, codeGenerator, context);
gd::ExpressionParser parser(instruction.GetParameter(i).GetPlainString());
parser.ParseStringExpression(CppPlatform::Get(), project, scene, callbacks);
if (parameterCode.empty()) parameterCode = "\"\"";
code += "functionParameters.push_back("+parameterCode+");\n";
}
code += "std::vector<std::string> * oldFunctionParameters = currentFunctionParameters;\n";
code += "currentFunctionParameters = &functionParameters;\n";
code += FunctionEvent::MangleFunctionName(*functionEvent)+"(runtimeContext, "+objectsAsArgumentCode+");\n";
code += "currentFunctionParameters = oldFunctionParameters;\n";
return code;
};