Simplified BridgeArgument wrapper
This commit is contained in:
@@ -11,7 +11,7 @@ using namespace speckle::utility;
|
||||
Default constructor
|
||||
--------------------------------------------------------------------*/
|
||||
UpdateConfig::UpdateConfig() : BridgeMethod{"UpdateConfig", [&](UpdateArgs args) {
|
||||
run(args.value);
|
||||
run(args);
|
||||
}} {}
|
||||
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace connector::interfac::browser::bridge {
|
||||
/*!
|
||||
Object for testing JS comms (with TestBridge binding)
|
||||
*/
|
||||
class SayHiArg final : public active::serialise::Package {
|
||||
class SayHiArg : public active::serialise::Package {
|
||||
public:
|
||||
|
||||
// MARK: - Types
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace {
|
||||
Default constructor
|
||||
--------------------------------------------------------------------*/
|
||||
SayHi::SayHi() : BridgeMethod{"SayHi", [&](SayHiWrapper arg) {
|
||||
return run(arg.value);
|
||||
return run(arg);
|
||||
}} {}
|
||||
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace {
|
||||
Default constructor
|
||||
--------------------------------------------------------------------*/
|
||||
TriggerEvent::TriggerEvent() : BridgeMethod{"TriggerEvent", [&](TriggerEventWrapper arg) {
|
||||
return run(arg.value);
|
||||
return run(arg);
|
||||
}} {}
|
||||
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace speckle::interfac::browser::bridge {
|
||||
- Create the correct BridgeArgument subclass for the emthod/argument and populate it with the collected attributes
|
||||
Therefore, there is no need for this class to handle any deserialisation, and subclasses should only handle the core arguments data
|
||||
*/
|
||||
class BridgeArgument : public active::serialise::Package {
|
||||
class BridgeArgument : public active::serialise::Cargo {
|
||||
public:
|
||||
|
||||
// MARK: - Constructors
|
||||
@@ -99,7 +99,7 @@ namespace speckle::interfac::browser::bridge {
|
||||
|
||||
///Definition of the argument for a JS callable method (enclosing the local function argument)
|
||||
template<typename T, uint32_t Params = 1>
|
||||
class JSArgType : public BridgeArgument {
|
||||
class JSArgType : public BridgeArgument, public T {
|
||||
public:
|
||||
|
||||
/*!
|
||||
@@ -112,42 +112,21 @@ namespace speckle::interfac::browser::bridge {
|
||||
const speckle::utility::String& requestID,
|
||||
const speckle::utility::String::Option& errorMessage = std::nullopt) : BridgeArgument{methodName, requestID, errorMessage} {
|
||||
//Tag the argument object as a template where possible
|
||||
if (auto arg = dynamic_cast<ArgumentBase*>(&value); arg != nullptr)
|
||||
if (auto arg = dynamic_cast<ArgumentBase*>(this); arg != nullptr)
|
||||
arg->setArgumentTemplate(true);
|
||||
}
|
||||
/*!
|
||||
Copy constructor
|
||||
@param source The object to copy
|
||||
*/
|
||||
JSArgType(const JSArgType& source) : BridgeArgument{source}, value{source.value} {}
|
||||
|
||||
/*!
|
||||
Get the number of parameters in the argument
|
||||
@return The number of parameters
|
||||
*/
|
||||
uint32_t parameterCount() const override { return Params; }
|
||||
/*!
|
||||
Fill an inventory with the cargo items
|
||||
@param inventory The inventory to receive the cargo items
|
||||
@return True if items have been added to the inventory
|
||||
*/
|
||||
bool fillInventory(active::serialise::Inventory& inventory) const override { return value.fillInventory(inventory); }
|
||||
/*!
|
||||
Get the specified cargo
|
||||
@param item The inventory item to retrieve
|
||||
@return The requested cargo (nullptr on failure
|
||||
*/
|
||||
Cargo::Unique getCargo(const active::serialise::Inventory::Item& item) const override { return value.getCargo(item); }
|
||||
JSArgType(const JSArgType& source) : BridgeArgument{source}, T{source} {}
|
||||
|
||||
// MARK: - Functions (mutating)
|
||||
|
||||
/*!
|
||||
Set to the default package content
|
||||
*/
|
||||
void setDefault() override { return value.setDefault(); }
|
||||
|
||||
T value;
|
||||
};
|
||||
/*!
|
||||
Get the number of parameters in the argument
|
||||
@return The number of parameters
|
||||
*/
|
||||
uint32_t parameterCount() const override { return Params; }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
21F69EBE2C63C954008B6A06 /* Link.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21F69EBD2C63C954008B6A06 /* Link.cpp */; };
|
||||
21F69F3B2C6B880C008B6A06 /* JSBaseTransport.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21F69F382C6B880B008B6A06 /* JSBaseTransport.cpp */; };
|
||||
21F69F512C6CCC25008B6A06 /* BrowserBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21F69F4A2C6CCC25008B6A06 /* BrowserBridge.cpp */; };
|
||||
21F69F5A2C6CDB67008B6A06 /* FunctionBinding.h in Headers */ = {isa = PBXBuildFile; fileRef = 21F69F592C6CDB67008B6A06 /* FunctionBinding.h */; };
|
||||
21F69F612C6D0286008B6A06 /* GetBindingsMethodNames.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21F69F602C6D0286008B6A06 /* GetBindingsMethodNames.cpp */; };
|
||||
21F69F682C6DFB01008B6A06 /* RunMethod.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21F69F662C6DFB01008B6A06 /* RunMethod.cpp */; };
|
||||
21F69F7E2C6FD9FC008B6A06 /* GetCallResult.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21F69F7A2C6FD9FC008B6A06 /* GetCallResult.cpp */; };
|
||||
@@ -115,7 +114,6 @@
|
||||
21F69F4D2C6CCC25008B6A06 /* BridgeArgument.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BridgeArgument.h; sourceTree = "<group>"; };
|
||||
21F69F4F2C6CCC25008B6A06 /* BridgeMethod.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BridgeMethod.h; sourceTree = "<group>"; };
|
||||
21F69F572C6CDAEE008B6A06 /* GetBindingsMethodNames.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GetBindingsMethodNames.h; sourceTree = "<group>"; };
|
||||
21F69F592C6CDB67008B6A06 /* FunctionBinding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FunctionBinding.h; sourceTree = "<group>"; };
|
||||
21F69F602C6D0286008B6A06 /* GetBindingsMethodNames.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GetBindingsMethodNames.cpp; sourceTree = "<group>"; };
|
||||
21F69F652C6DFB01008B6A06 /* RunMethod.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RunMethod.h; sourceTree = "<group>"; };
|
||||
21F69F662C6DFB01008B6A06 /* RunMethod.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RunMethod.cpp; sourceTree = "<group>"; };
|
||||
@@ -333,7 +331,6 @@
|
||||
children = (
|
||||
21B67D0C2C7E0E8D00FD64FC /* ErrorReport.cpp */,
|
||||
21B67D092C7E0E8D00FD64FC /* ErrorReport.h */,
|
||||
21F69F592C6CDB67008B6A06 /* FunctionBinding.h */,
|
||||
21F69F602C6D0286008B6A06 /* GetBindingsMethodNames.cpp */,
|
||||
21F69F572C6CDAEE008B6A06 /* GetBindingsMethodNames.h */,
|
||||
21F69F7A2C6FD9FC008B6A06 /* GetCallResult.cpp */,
|
||||
@@ -390,7 +387,6 @@
|
||||
isa = PBXHeadersBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
21F69F5A2C6CDB67008B6A06 /* FunctionBinding.h in Headers */,
|
||||
210CC86F2C7E879700610F58 /* ArgumentBase.h in Headers */,
|
||||
21B67D0D2C7E0E8D00FD64FC /* ErrorReport.h in Headers */,
|
||||
21B67D002C7CE15100FD64FC /* Exception.h in Headers */,
|
||||
|
||||
Reference in New Issue
Block a user