[Bf-blender-cvs] [d021d633ffe] temp-socket-decl-refactor: cleanup
Jacques Lucke
noreply at git.blender.org
Wed Sep 15 14:30:00 CEST 2021
Commit: d021d633ffe7866e8d37b85e7169a90e5f7542fa
Author: Jacques Lucke
Date: Wed Sep 15 13:54:04 2021 +0200
Branches: temp-socket-decl-refactor
https://developer.blender.org/rBd021d633ffe7866e8d37b85e7169a90e5f7542fa
cleanup
===================================================================
M source/blender/nodes/NOD_socket_declarations.hh
M source/blender/nodes/intern/node_socket_declarations.cc
===================================================================
diff --git a/source/blender/nodes/NOD_socket_declarations.hh b/source/blender/nodes/NOD_socket_declarations.hh
index 6dbc7b57ff7..48cf6cf54fc 100644
--- a/source/blender/nodes/NOD_socket_declarations.hh
+++ b/source/blender/nodes/NOD_socket_declarations.hh
@@ -211,54 +211,25 @@ class String : public SocketDeclaration {
class StringBuilder : public SocketDeclarationBuilder<String> {
};
-namespace detail {
-struct CommonIDSocketData {
- const char *idname;
-};
-
-bNodeSocket &build_id_socket(const SocketDeclaration &decl,
- bNodeTree &ntree,
- bNode &node,
- eNodeSocketInOut in_out,
- const CommonIDSocketData &data);
-bool matches_id_socket(const SocketDeclaration &decl,
- const bNodeSocket &socket,
- const CommonIDSocketData &data);
-
class IDSocketDeclaration : public SocketDeclaration {
private:
- CommonIDSocketData data_;
+ const char *idname_;
public:
- IDSocketDeclaration(const char *idname) : data_({idname})
- {
- }
-
- bNodeSocket &build(bNodeTree &ntree, bNode &node, eNodeSocketInOut in_out) const override
- {
- return build_id_socket(*this, ntree, node, in_out, data_);
- }
-
- bool matches(const bNodeSocket &socket) const override
+ IDSocketDeclaration(const char *idname) : idname_(idname)
{
- return matches_id_socket(*this, socket, data_);
}
- bNodeSocket &update_or_build(bNodeTree &ntree, bNode &node, bNodeSocket &socket) const override
- {
- if (StringRef(socket.idname) != data_.idname) {
- return this->build(ntree, node, (eNodeSocketInOut)socket.in_out);
- }
- return socket;
- }
+ bNodeSocket &build(bNodeTree &ntree, bNode &node, eNodeSocketInOut in_out) const override;
+ bool matches(const bNodeSocket &socket) const override;
+ bNodeSocket &update_or_build(bNodeTree &ntree, bNode &node, bNodeSocket &socket) const override;
};
-} // namespace detail
-class Object : public detail::IDSocketDeclaration {
+class Object : public IDSocketDeclaration {
public:
using Builder = class ObjectBuilder;
- Object() : detail::IDSocketDeclaration("NodeSocketObject")
+ Object() : IDSocketDeclaration("NodeSocketObject")
{
}
};
@@ -266,11 +237,11 @@ class Object : public detail::IDSocketDeclaration {
class ObjectBuilder : public SocketDeclarationBuilder<Object> {
};
-class Material : public detail::IDSocketDeclaration {
+class Material : public IDSocketDeclaration {
public:
using Builder = class MaterialBuilder;
- Material() : detail::IDSocketDeclaration("NodeSocketMaterial")
+ Material() : IDSocketDeclaration("NodeSocketMaterial")
{
}
};
@@ -278,11 +249,11 @@ class Material : public detail::IDSocketDeclaration {
class MaterialBuilder : public SocketDeclarationBuilder<Material> {
};
-class Collection : public detail::IDSocketDeclaration {
+class Collection : public IDSocketDeclaration {
public:
using Builder = class CollectionBuilder;
- Collection() : detail::IDSocketDeclaration("NodeSocketCollection")
+ Collection() : IDSocketDeclaration("NodeSocketCollection")
{
}
};
@@ -290,11 +261,11 @@ class Collection : public detail::IDSocketDeclaration {
class CollectionBuilder : public SocketDeclarationBuilder<Collection> {
};
-class Texture : public detail::IDSocketDeclaration {
+class Texture : public IDSocketDeclaration {
public:
using Builder = class TextureBuilder;
- Texture() : detail::IDSocketDeclaration("NodeSocketTexture")
+ Texture() : IDSocketDeclaration("NodeSocketTexture")
{
}
};
diff --git a/source/blender/nodes/intern/node_socket_declarations.cc b/source/blender/nodes/intern/node_socket_declarations.cc
index 08cf0de92d0..4b0dbad3cff 100644
--- a/source/blender/nodes/intern/node_socket_declarations.cc
+++ b/source/blender/nodes/intern/node_socket_declarations.cc
@@ -263,32 +263,37 @@ bool String::matches(const bNodeSocket &socket) const
* IDSocketDeclaration.
*/
-namespace detail {
-bNodeSocket &build_id_socket(const SocketDeclaration &decl,
- bNodeTree &ntree,
- bNode &node,
- eNodeSocketInOut in_out,
- const CommonIDSocketData &data)
+bNodeSocket &IDSocketDeclaration::build(bNodeTree &ntree,
+ bNode &node,
+ eNodeSocketInOut in_out) const
{
bNodeSocket &socket = *nodeAddSocket(
- &ntree, &node, in_out, data.idname, decl.identifier().c_str(), decl.name().c_str());
- decl.set_common_flags(socket);
+ &ntree, &node, in_out, idname_, identifier_.c_str(), name_.c_str());
+ this->set_common_flags(socket);
return socket;
}
-bool matches_id_socket(const SocketDeclaration &decl,
- const bNodeSocket &socket,
- const CommonIDSocketData &data)
+bool IDSocketDeclaration::matches(const bNodeSocket &socket) const
{
- if (!decl.matches_common_data(socket)) {
+ if (!this->matches_common_data(socket)) {
return false;
}
- if (!STREQ(socket.idname, data.idname)) {
+ if (!STREQ(socket.idname, idname_)) {
return false;
}
return true;
}
-} // namespace detail
+
+bNodeSocket &IDSocketDeclaration::update_or_build(bNodeTree &ntree,
+ bNode &node,
+ bNodeSocket &socket) const
+{
+ if (StringRef(socket.idname) != idname_) {
+ return this->build(ntree, node, (eNodeSocketInOut)socket.in_out);
+ }
+ this->set_common_flags(socket);
+ return socket;
+}
/* --------------------------------------------------------------------
* Geometry.
More information about the Bf-blender-cvs
mailing list