Allow instructions/expressions to be marked as private

This commit is contained in:
Florian Rival
2019-06-16 14:54:06 +01:00
committed by Florian Rival
parent b5acc58b41
commit 64db614914
6 changed files with 75 additions and 20 deletions

View File

@@ -20,7 +20,8 @@ ExpressionMetadata::ExpressionMetadata(const gd::String& extensionNamespace_,
group(group_),
shown(true),
smallIconFilename(smallicon_),
extensionNamespace(extensionNamespace_) {
extensionNamespace(extensionNamespace_),
isPrivate(false) {
}
ExpressionMetadata& ExpressionMetadata::SetHidden() {

View File

@@ -112,19 +112,29 @@ class ExpressionCodeGenerationInformation {
};
/**
* \brief Contains user-friendly infos about expressions and members needed to
* setup an expression
* \brief Describe user-friendly information about an expression, its parameters
* and the function name as well as other information for code generation.
*
* \ingroup Events
*/
class GD_CORE_API ExpressionMetadata {
public:
/**
* Construct a new expression metadata.
*/
ExpressionMetadata(const gd::String& extensionNamespace,
const gd::String& name,
const gd::String& fullname,
const gd::String& description,
const gd::String& group,
const gd::String& smallicon);
/**
* Construct an empty ExpressionMetadata.
* \warning Don't use this - only here to fullfil std::map requirements.
*/
ExpressionMetadata() : shown(false), isPrivate(false){};
virtual ~ExpressionMetadata(){};
/**
@@ -140,6 +150,21 @@ class GD_CORE_API ExpressionMetadata {
return *this;
}
/**
* Check if the instruction is private - it can't be used outside of the
* object/ behavior that it is attached too.
*/
bool IsPrivate() const { return isPrivate; }
/**
* Set that the instruction is private - it can't be used outside of the
* object/ behavior that it is attached too.
*/
ExpressionMetadata& SetPrivate() {
isPrivate = true;
return *this;
}
/**
* \see gd::InstructionMetadata::AddParameter
*/
@@ -187,10 +212,6 @@ class GD_CORE_API ExpressionMetadata {
ExpressionCodeGenerationInformation codeExtraInformation;
/** Don't use this constructor. Only here to fullfil std::map requirements
*/
ExpressionMetadata() : shown(false){};
bool IsShown() const { return shown; }
const gd::String& GetFullName() const { return fullname; }
const gd::String& GetDescription() const { return description; }
@@ -203,7 +224,9 @@ class GD_CORE_API ExpressionMetadata {
return parameters[id];
};
std::size_t GetParametersCount() const { return parameters.size(); };
const std::vector<gd::ParameterMetadata> & GetParameters() const { return parameters; };
const std::vector<gd::ParameterMetadata>& GetParameters() const {
return parameters;
};
std::vector<gd::ParameterMetadata> parameters;
@@ -215,6 +238,7 @@ class GD_CORE_API ExpressionMetadata {
gd::String smallIconFilename;
gd::String extensionNamespace;
bool isPrivate;
};
} // namespace gd

View File

@@ -17,7 +17,9 @@ InstructionMetadata::InstructionMetadata()
// and *fast* to use a
// InstructionMetadata.
canHaveSubInstructions(false),
hidden(true) {}
hidden(true),
usageComplexity(5),
isPrivate(false) {}
InstructionMetadata::InstructionMetadata(const gd::String& extensionNamespace_,
const gd::String& name_,
@@ -37,7 +39,8 @@ InstructionMetadata::InstructionMetadata(const gd::String& extensionNamespace_,
canHaveSubInstructions(false),
extensionNamespace(extensionNamespace_),
hidden(false),
usageComplexity(5) {
usageComplexity(5),
isPrivate(false) {
}
ParameterMetadata::ParameterMetadata() : optional(false), codeOnly(false) {}

View File

@@ -215,13 +215,17 @@ class GD_CORE_API ParameterMetadata {
};
/**
* \brief Contains user-friendly infos about actions/conditions, and members
* needed to setup an instruction
* \brief Describe user-friendly information about an instruction (action or
* condition), its parameters and the function name as well as other information
* for code generation.
*
* \ingroup Events
*/
class GD_CORE_API InstructionMetadata {
public:
/**
* Construct a new instruction metadata.
*/
InstructionMetadata(const gd::String &extensionNamespace,
const gd::String &name,
const gd::String &fullname,
@@ -230,6 +234,13 @@ class GD_CORE_API InstructionMetadata {
const gd::String &group,
const gd::String &icon,
const gd::String &smallIcon);
/**
* Construct an empty InstructionMetadata.
* \warning Don't use this - only here to fullfil std::map requirements.
*/
InstructionMetadata();
virtual ~InstructionMetadata(){};
const gd::String &GetFullName() const { return fullname; }
@@ -261,6 +272,21 @@ class GD_CORE_API InstructionMetadata {
return *this;
}
/**
* Check if the instruction is private - it can't be used outside of the
* object/ behavior that it is attached too.
*/
bool IsPrivate() const { return isPrivate; }
/**
* Set that the instruction is private - it can't be used outside of the
* object/ behavior that it is attached too.
*/
InstructionMetadata &SetPrivate() {
isPrivate = true;
return *this;
}
/**
* Notify that the instruction can have sub instructions.
*/
@@ -516,12 +542,6 @@ class GD_CORE_API InstructionMetadata {
return codeExtraInformation.SetFunctionName(functionName);
}
/** \brief DefaultConstructor.
* \warning Please do not use this constructor. Only here to fulfill std::map
* requirements.
*/
InstructionMetadata();
std::vector<ParameterMetadata> parameters;
private:
@@ -537,6 +557,7 @@ class GD_CORE_API InstructionMetadata {
bool hidden;
int usageComplexity; ///< Evaluate the instruction from 0 (simple&easy to
///< use) to 10 (complex to understand)
bool isPrivate;
};
} // namespace gd

View File

@@ -894,11 +894,12 @@ interface InstructionMetadata {
[Const, Ref] VectorParameterMetadata GetParameters();
long GetUsageComplexity();
boolean IsHidden();
boolean IsPrivate();
[Ref] InstructionMetadata SetCanHaveSubInstructions();
[Ref] InstructionMetadata SetHelpPath([Const] DOMString helpPath);
[Ref] InstructionMetadata SetHidden();
[Ref] InstructionMetadata SetGroup([Const] DOMString group); //TODO: check if useful
[Ref] InstructionMetadata SetPrivate();
[Ref] InstructionMetadata AddParameter([Const] DOMString type,
[Const] DOMString description,
[Const] DOMString optionalObjectType,
@@ -919,12 +920,13 @@ interface ExpressionMetadata {
[Const, Ref] DOMString GetGroup();
[Const, Ref] DOMString GetSmallIconFilename();
boolean IsShown();
boolean IsPrivate();
[Ref] ParameterMetadata GetParameter(unsigned long id);
unsigned long GetParametersCount();
[Const, Ref] VectorParameterMetadata GetParameters();
[Ref] ExpressionMetadata SetHidden();
[Ref] ExpressionMetadata SetGroup([Const] DOMString str); //TODO: check if useful
[Ref] ExpressionMetadata SetPrivate();
[Ref] ExpressionMetadata AddParameter(
[Const] DOMString type,
[Const] DOMString description,

View File

@@ -289,6 +289,10 @@ export const declareBehaviorPropertiesInstructionAndExpressions = (
false
);
// All property actions/conditions/expressions are private, meaning
// they can only be used from the behavior events.
instructionOrExpression.setPrivate();
return instructionOrExpression;
};