[Bf-blender-cvs] [2daab407171] blender2.8: Depsgraph: Cleanup, simplify operation code stringification
Sergey Sharybin
noreply at git.blender.org
Tue May 1 10:24:32 CEST 2018
Commit: 2daab407171479aed012d539a546e99ee095d318
Author: Sergey Sharybin
Date: Mon Apr 30 17:20:42 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB2daab407171479aed012d539a546e99ee095d318
Depsgraph: Cleanup, simplify operation code stringification
===================================================================
M source/blender/depsgraph/intern/builder/deg_builder_relations.cc
M source/blender/depsgraph/intern/builder/deg_builder_relations_keys.cc
M source/blender/depsgraph/intern/depsgraph_type_defines.cc
M source/blender/depsgraph/intern/depsgraph_types.h
M source/blender/depsgraph/intern/nodes/deg_node_operation.cc
===================================================================
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index f1869fdd916..201df94b691 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -211,7 +211,7 @@ OperationDepsNode *DepsgraphRelationBuilder::get_node(
OperationDepsNode *op_node = find_node(key);
if (op_node == NULL) {
fprintf(stderr, "find_node_operation: Failed for (%s, '%s')\n",
- DEG_OPNAMES[key.opcode], key.name);
+ operationCodeAsString(key.opcode), key.name);
}
return op_node;
}
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_keys.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_keys.cc
index 4b8e4faae3f..a965d890496 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations_keys.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_keys.cc
@@ -179,7 +179,7 @@ string OperationKey::identifier() const
return string("OperationKey(") +
"t: " + typebuf +
", cn: '" + component_name +
- "', c: " + DEG_OPNAMES[opcode] +
+ "', c: " + operationCodeAsString(opcode) +
", n: '" + name + "')";
}
diff --git a/source/blender/depsgraph/intern/depsgraph_type_defines.cc b/source/blender/depsgraph/intern/depsgraph_type_defines.cc
index c4fc9591611..5412573b936 100644
--- a/source/blender/depsgraph/intern/depsgraph_type_defines.cc
+++ b/source/blender/depsgraph/intern/depsgraph_type_defines.cc
@@ -73,9 +73,7 @@ DepsNodeFactory *deg_type_get_factory(const eDepsNode_Type type)
/* Stringified opcodes ------------------------------------- */
-DepsOperationStringifier DEG_OPNAMES;
-
-static const char *stringify_opcode(eDepsOperation_Code opcode)
+const char* operationCodeAsString(eDepsOperation_Code opcode)
{
switch (opcode) {
#define STRINGIFY_OPCODE(name) case DEG_OPCODE_##name: return #name
@@ -143,22 +141,6 @@ static const char *stringify_opcode(eDepsOperation_Code opcode)
return "UNKNOWN";
}
-DepsOperationStringifier::DepsOperationStringifier()
-{
- for (int i = 0; i < DEG_NUM_OPCODES; ++i) {
- names_[i] = stringify_opcode((eDepsOperation_Code)i);
- }
-}
-
-const char *DepsOperationStringifier::operator[](eDepsOperation_Code opcode)
-{
- BLI_assert((opcode >= 0) && (opcode < DEG_NUM_OPCODES));
- if (opcode >= 0 && opcode < DEG_NUM_OPCODES) {
- return names_[opcode];
- }
- return "UnknownOpcode";
-}
-
} // namespace DEG
/* Register all node types */
diff --git a/source/blender/depsgraph/intern/depsgraph_types.h b/source/blender/depsgraph/intern/depsgraph_types.h
index 6d328b399e0..1d3318a2988 100644
--- a/source/blender/depsgraph/intern/depsgraph_types.h
+++ b/source/blender/depsgraph/intern/depsgraph_types.h
@@ -268,16 +268,6 @@ typedef enum eDepsOperation_Code {
DEG_NUM_OPCODES,
} eDepsOperation_Code;
-/* Some magic to stringify operation codes. */
-class DepsOperationStringifier {
-public:
- DepsOperationStringifier();
- const char *operator[](eDepsOperation_Code opcodex);
-protected:
- const char *names_[DEG_NUM_OPCODES];
-};
-
-/* String defines for these opcodes, defined in depsgraph_type_defines.cpp */
-extern DepsOperationStringifier DEG_OPNAMES;
+const char* operationCodeAsString(eDepsOperation_Code opcode);
} // namespace DEG
diff --git a/source/blender/depsgraph/intern/nodes/deg_node_operation.cc b/source/blender/depsgraph/intern/nodes/deg_node_operation.cc
index cbc0fbb4241..e82bbbc0e8a 100644
--- a/source/blender/depsgraph/intern/nodes/deg_node_operation.cc
+++ b/source/blender/depsgraph/intern/nodes/deg_node_operation.cc
@@ -56,7 +56,7 @@ OperationDepsNode::~OperationDepsNode()
string OperationDepsNode::identifier() const
{
- return string(DEG_OPNAMES[opcode]) + "(" + name + ")";
+ return string(operationCodeAsString(opcode)) + "(" + name + ")";
}
/* Full node identifier, including owner name.
More information about the Bf-blender-cvs
mailing list