GDevelop JS Platform
Platform for developing HTML5/Javascript based games with GDevelop
 All Classes Files Functions Variables Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
gdjs::EventsCodeGenerator Class Reference

The class being responsible for generating JavaScript code from events. More...

#include <EventsCodeGenerator.h>

Inherits EventsCodeGenerator.

Public Member Functions

virtual gd::String GenerateEventsListCode (gd::EventsList &events, const gd::EventsCodeGenerationContext &context)
 Generate code for executing an event list. More...
 
virtual gd::String GenerateConditionsListCode (gd::InstructionsList &conditions, gd::EventsCodeGenerationContext &context)
 
virtual gd::String GenerateBooleanFullName (const gd::String &boolName, const gd::EventsCodeGenerationContext &context)
 Generate the full name for accessing to a boolean variable used for conditions.
 
virtual gd::String GenerateBooleanInitializationToFalse (const gd::String &boolName, const gd::EventsCodeGenerationContext &context)
 Set a boolean to false.
 
virtual gd::String GetObjectListName (const gd::String &name, const gd::EventsCodeGenerationContext &context)
 Get the full name for accessing to a list of objects.
 
virtual gd::String GetCodeNamespaceAccessor ()
 Get the namespace to be used to store code generated objects/values/functions, with the extra "dot" at the end to be used to access to a property/member. More...
 
virtual gd::String GetCodeNamespace ()
 Get the namespace to be used to store code generated objects/values/functions. More...
 
void SetCodeNamespace (const gd::String &codeNamespace_)
 Specify the code namespace to use, useful for functions as it is not autogenerated. More...
 

Static Public Member Functions

static gd::String GenerateLayoutCode (gd::Project &project, const gd::Layout &scene, const gd::String &codeNamespace, std::set< gd::String > &includeFiles, bool compilationForRuntime=false)
 
static gd::String GenerateEventsFunctionCode (gd::Project &project, const gd::EventsFunction &eventsFunction, const gd::String &codeNamespace, std::set< gd::String > &includeFiles, bool compilationForRuntime=false)
 
static gd::String GenerateBehaviorEventsFunctionCode (gd::Project &project, const gd::EventsFunction &eventsFunction, const gd::String &codeNamespace, const gd::String &fullyQualifiedFunctionName, std::set< gd::String > &includeFiles, bool compilationForRuntime=false)
 

Protected Member Functions

virtual gd::String GenerateParameterCodes (const gd::String &parameter, const gd::ParameterMetadata &metadata, gd::EventsCodeGenerationContext &context, const gd::String &lastObjectName, std::vector< std::pair< gd::String, gd::String > > *supplementaryParametersTypes)
 
virtual gd::String GenerateObjectFunctionCall (gd::String objectListName, const gd::ObjectMetadata &objMetadata, const gd::ExpressionCodeGenerationInformation &codeInfo, gd::String parametersStr, gd::String defaultOutput, gd::EventsCodeGenerationContext &context)
 
virtual gd::String GenerateObjectBehaviorFunctionCall (gd::String objectListName, gd::String behaviorName, const gd::BehaviorMetadata &autoInfo, const gd::ExpressionCodeGenerationInformation &codeInfo, gd::String parametersStr, gd::String defaultOutput, gd::EventsCodeGenerationContext &context)
 
virtual gd::String GenerateFreeCondition (const std::vector< gd::String > &arguments, const gd::InstructionMetadata &instrInfos, const gd::String &returnBoolean, bool conditionInverted, gd::EventsCodeGenerationContext &context)
 
virtual gd::String GenerateObjectCondition (const gd::String &objectName, const gd::ObjectMetadata &objInfo, const std::vector< gd::String > &arguments, const gd::InstructionMetadata &instrInfos, const gd::String &returnBoolean, bool conditionInverted, gd::EventsCodeGenerationContext &context)
 
virtual gd::String GenerateBehaviorCondition (const gd::String &objectName, const gd::String &behaviorName, const gd::BehaviorMetadata &autoInfo, const std::vector< gd::String > &arguments, const gd::InstructionMetadata &instrInfos, const gd::String &returnBoolean, bool conditionInverted, gd::EventsCodeGenerationContext &context)
 
virtual gd::String GenerateObjectAction (const gd::String &objectName, const gd::ObjectMetadata &objInfo, const std::vector< gd::String > &arguments, const gd::InstructionMetadata &instrInfos, gd::EventsCodeGenerationContext &context)
 
virtual gd::String GenerateBehaviorAction (const gd::String &objectName, const gd::String &behaviorName, const gd::BehaviorMetadata &autoInfo, const std::vector< gd::String > &arguments, const gd::InstructionMetadata &instrInfos, gd::EventsCodeGenerationContext &context)
 
virtual gd::String GenerateGetBehaviorNameCode (const gd::String &behaviorName)
 
virtual gd::String GenerateGetVariable (const gd::String &variableName, const VariableScope &scope, gd::EventsCodeGenerationContext &context, const gd::String &objectName)
 
virtual gd::String GenerateVariableAccessor (gd::String childName)
 
virtual gd::String GenerateVariableBracketAccessor (gd::String expressionCode)
 
virtual gd::String GenerateBadVariable ()
 
virtual gd::String GenerateBadObject ()
 
virtual gd::String GenerateObject (const gd::String &objectName, const gd::String &type, gd::EventsCodeGenerationContext &context)
 
virtual gd::String GenerateNegatedPredicat (const gd::String &predicat) const
 
virtual gd::String GenerateReferenceToUpperScopeBoolean (const gd::String &referenceName, const gd::String &referencedBoolean, gd::EventsCodeGenerationContext &context)
 
virtual gd::String GenerateObjectsDeclarationCode (gd::EventsCodeGenerationContext &context)
 
virtual gd::String GenerateAllInstancesGetterCode (gd::String &objectName)
 
virtual gd::String GenerateProfilerSectionBegin (const gd::String &section)
 
virtual gd::String GenerateProfilerSectionEnd (const gd::String &section)
 

Detailed Description

The class being responsible for generating JavaScript code from events.

See also gd::EventsCodeGenerator.

Member Function Documentation

gd::String gdjs::EventsCodeGenerator::GenerateBehaviorEventsFunctionCode ( gd::Project &  project,
const gd::EventsFunction &  eventsFunction,
const gd::String &  codeNamespace,
const gd::String &  fullyQualifiedFunctionName,
std::set< gd::String > &  includeFiles,
bool  compilationForRuntime = false 
)
static

Generate JavaScript for executing events of a events based behavior function.

Parameters
projectProject used.
eventsFunctionThe events function to be compiled.
codeNamespaceWhere to store the context used by the function.
includeFilesWill be filled with the necessary include files.
compilationForRuntimeSet this to true if the code is generated for runtime.
Returns
JavaScript code
gd::String gdjs::EventsCodeGenerator::GenerateConditionsListCode ( gd::InstructionsList &  conditions,
gd::EventsCodeGenerationContext &  context 
)
virtual

Generate code for executing a condition list

Parameters
gameGame used
sceneScene used
conditionsstd::vector of conditions
contextContext used for generation
Returns
JS code.
gd::String gdjs::EventsCodeGenerator::GenerateEventsFunctionCode ( gd::Project &  project,
const gd::EventsFunction &  eventsFunction,
const gd::String &  codeNamespace,
std::set< gd::String > &  includeFiles,
bool  compilationForRuntime = false 
)
static

Generate JavaScript for executing events of an events based function.

Parameters
projectProject used.
eventsFunctionThe events function to be compiled.
codeNamespaceWhere to store the context used by the function.
includeFilesWill be filled with the necessary include files.
compilationForRuntimeSet this to true if the code is generated for runtime.
Returns
JavaScript code
gd::String gdjs::EventsCodeGenerator::GenerateEventsListCode ( gd::EventsList &  events,
const gd::EventsCodeGenerationContext &  context 
)
virtual

Generate code for executing an event list.

Note
To reduce the stress on JS engines, the code is generated inside a separate JS function (see gd::EventsCodeGenerator::AddCustomCodeOutsideMain). This method will return the code to call this separate function.
Parameters
eventsstd::vector of events
contextContext used for generation
Returns
Code
gd::String gdjs::EventsCodeGenerator::GenerateLayoutCode ( gd::Project &  project,
const gd::Layout &  scene,
const gd::String &  codeNamespace,
std::set< gd::String > &  includeFiles,
bool  compilationForRuntime = false 
)
static

Generate JavaScript for executing events of a scene

Parameters
projectProject the scene belongs to.
sceneThe scene to generate the code for.
includeFilesWill be filled with the necessary include files.
compilationForRuntimeSet this to true if the code is generated for runtime.
Returns
JavaScript code
virtual gd::String gdjs::EventsCodeGenerator::GetCodeNamespace ( )
inlinevirtual

Get the namespace to be used to store code generated objects/values/functions.

Example: "gdjs.something"

virtual gd::String gdjs::EventsCodeGenerator::GetCodeNamespaceAccessor ( )
inlinevirtual

Get the namespace to be used to store code generated objects/values/functions, with the extra "dot" at the end to be used to access to a property/member.

Example: "gdjs.something."

void gdjs::EventsCodeGenerator::SetCodeNamespace ( const gd::String &  codeNamespace_)
inline

Specify the code namespace to use, useful for functions as it is not autogenerated.

Example: "gdjs.something"


The documentation for this class was generated from the following files: