feat: Added bitwise shift left/right data processor nodes
This commit is contained in:
parent
5d50a3927e
commit
79e25b0889
@ -282,6 +282,10 @@
|
|||||||
"hex.builtin.nodes.bitwise.not.header": "Bitwise NOT",
|
"hex.builtin.nodes.bitwise.not.header": "Bitwise NOT",
|
||||||
"hex.builtin.nodes.bitwise.or": "OR",
|
"hex.builtin.nodes.bitwise.or": "OR",
|
||||||
"hex.builtin.nodes.bitwise.or.header": "Bitwise OR",
|
"hex.builtin.nodes.bitwise.or.header": "Bitwise OR",
|
||||||
|
"hex.builtin.nodes.bitwise.shift_left": "Shift Left",
|
||||||
|
"hex.builtin.nodes.bitwise.shift_left.header": "Bitwise Shift Left",
|
||||||
|
"hex.builtin.nodes.bitwise.shift_right": "Shift Right",
|
||||||
|
"hex.builtin.nodes.bitwise.shift_right.header": "Bitwise Shift Right",
|
||||||
"hex.builtin.nodes.bitwise.swap": "Reverse",
|
"hex.builtin.nodes.bitwise.swap": "Reverse",
|
||||||
"hex.builtin.nodes.bitwise.swap.header": "Reverse bits",
|
"hex.builtin.nodes.bitwise.swap.header": "Reverse bits",
|
||||||
"hex.builtin.nodes.bitwise.xor": "XOR",
|
"hex.builtin.nodes.bitwise.xor": "XOR",
|
||||||
@ -321,6 +325,7 @@
|
|||||||
"hex.builtin.nodes.common.input.b": "Input B",
|
"hex.builtin.nodes.common.input.b": "Input B",
|
||||||
"hex.builtin.nodes.common.output": "Output",
|
"hex.builtin.nodes.common.output": "Output",
|
||||||
"hex.builtin.nodes.common.width": "Width",
|
"hex.builtin.nodes.common.width": "Width",
|
||||||
|
"hex.builtin.nodes.common.amount": "Amount",
|
||||||
"hex.builtin.nodes.constants": "Constants",
|
"hex.builtin.nodes.constants": "Constants",
|
||||||
"hex.builtin.nodes.constants.buffer": "Buffer",
|
"hex.builtin.nodes.constants.buffer": "Buffer",
|
||||||
"hex.builtin.nodes.constants.buffer.header": "Buffer",
|
"hex.builtin.nodes.constants.buffer.header": "Buffer",
|
||||||
|
@ -376,6 +376,63 @@ namespace hex::plugin::builtin {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class NodeBitwiseShiftLeft : public dp::Node {
|
||||||
|
public:
|
||||||
|
NodeBitwiseShiftLeft() : Node("hex.builtin.nodes.bitwise.shift_left.header", {
|
||||||
|
dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.common.input"),
|
||||||
|
dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.common.amount"),
|
||||||
|
dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Buffer, "hex.builtin.nodes.common.output")
|
||||||
|
}) { }
|
||||||
|
|
||||||
|
void process() override {
|
||||||
|
const auto &input = this->getBufferOnInput(0);
|
||||||
|
const auto &amount = this->getIntegerOnInput(1);
|
||||||
|
|
||||||
|
std::vector<u8> output = input;
|
||||||
|
|
||||||
|
for (u32 i = 0; i < amount; i += 1) {
|
||||||
|
u8 prevByte = 0x00;
|
||||||
|
for (auto &byte : output) {
|
||||||
|
auto startValue = byte;
|
||||||
|
|
||||||
|
byte <<= 1;
|
||||||
|
byte |= (prevByte & 0x80) >> 7;
|
||||||
|
prevByte = startValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this->setBufferOnOutput(2, output);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class NodeBitwiseShiftRight : public dp::Node {
|
||||||
|
public:
|
||||||
|
NodeBitwiseShiftRight() : Node("hex.builtin.nodes.bitwise.shift_left.header", {
|
||||||
|
dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.common.input"),
|
||||||
|
dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.common.amount"),
|
||||||
|
dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Buffer, "hex.builtin.nodes.common.output")
|
||||||
|
}) { }
|
||||||
|
|
||||||
|
void process() override {
|
||||||
|
const auto &input = this->getBufferOnInput(0);
|
||||||
|
const auto &amount = this->getIntegerOnInput(1);
|
||||||
|
|
||||||
|
std::vector<u8> output = input;
|
||||||
|
|
||||||
|
for (u32 i = 0; i < amount; i += 1) {
|
||||||
|
u8 prevByte = 0x00;
|
||||||
|
for (auto &byte : output | std::views::reverse) {
|
||||||
|
auto startValue = byte;
|
||||||
|
byte >>= 1;
|
||||||
|
byte |= (prevByte & 0x01) << 7;
|
||||||
|
prevByte = startValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this->setBufferOnOutput(2, output);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class NodeBitwiseADD : public dp::Node {
|
class NodeBitwiseADD : public dp::Node {
|
||||||
public:
|
public:
|
||||||
NodeBitwiseADD() : Node("hex.builtin.nodes.bitwise.add.header", { dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.common.input.a"), dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.common.input.b"), dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Buffer, "hex.builtin.nodes.common.output") }) { }
|
NodeBitwiseADD() : Node("hex.builtin.nodes.bitwise.add.header", { dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.common.input.a"), dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.common.input.b"), dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Buffer, "hex.builtin.nodes.common.output") }) { }
|
||||||
@ -1325,6 +1382,8 @@ namespace hex::plugin::builtin {
|
|||||||
ContentRegistry::DataProcessorNode::add<NodeBitwiseOR>("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.or");
|
ContentRegistry::DataProcessorNode::add<NodeBitwiseOR>("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.or");
|
||||||
ContentRegistry::DataProcessorNode::add<NodeBitwiseXOR>("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.xor");
|
ContentRegistry::DataProcessorNode::add<NodeBitwiseXOR>("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.xor");
|
||||||
ContentRegistry::DataProcessorNode::add<NodeBitwiseNOT>("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.not");
|
ContentRegistry::DataProcessorNode::add<NodeBitwiseNOT>("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.not");
|
||||||
|
ContentRegistry::DataProcessorNode::add<NodeBitwiseShiftLeft>("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.shift_left");
|
||||||
|
ContentRegistry::DataProcessorNode::add<NodeBitwiseShiftRight>("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.shift_right");
|
||||||
ContentRegistry::DataProcessorNode::add<NodeBitwiseSwap>("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.swap");
|
ContentRegistry::DataProcessorNode::add<NodeBitwiseSwap>("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.swap");
|
||||||
|
|
||||||
ContentRegistry::DataProcessorNode::add<NodeDecodingBase64>("hex.builtin.nodes.decoding", "hex.builtin.nodes.decoding.base64");
|
ContentRegistry::DataProcessorNode::add<NodeDecodingBase64>("hex.builtin.nodes.decoding", "hex.builtin.nodes.decoding.base64");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user