diff --git a/SpeckleConnector/Connector/Interface/Browser/Bridge/Account/AccountBridge.cpp b/SpeckleConnector/Connector/Interface/Browser/Bridge/Account/AccountBridge.cpp index 1397f4d..abca06a 100644 --- a/SpeckleConnector/Connector/Interface/Browser/Bridge/Account/AccountBridge.cpp +++ b/SpeckleConnector/Connector/Interface/Browser/Bridge/Account/AccountBridge.cpp @@ -1,10 +1,13 @@ #include "Connector/Interface/Browser/Bridge/Account/AccountBridge.h" +#include "Connector/Interface/Browser/Bridge/Account/GetAccounts.h" + using namespace connector::interface::browser::bridge; /*-------------------------------------------------------------------- Default constructor --------------------------------------------------------------------*/ -AccountBridge::AccountBridge() : BrowserBridge{"AccountBridge"} { - +AccountBridge::AccountBridge() : BrowserBridge{"accountsBinding"} { + //Add bridge methods + addMethod(); } //AccountBridge::AccountBridge diff --git a/SpeckleConnector/Connector/Interface/Browser/Bridge/Account/AccountBridge.h b/SpeckleConnector/Connector/Interface/Browser/Bridge/Account/AccountBridge.h index 7cfaeef..b08c6a3 100644 --- a/SpeckleConnector/Connector/Interface/Browser/Bridge/Account/AccountBridge.h +++ b/SpeckleConnector/Connector/Interface/Browser/Bridge/Account/AccountBridge.h @@ -17,6 +17,7 @@ namespace connector::interface::browser::bridge { // MARK: - Constructors + using base::base; /*! Default constructor */ diff --git a/SpeckleConnector/Connector/Interface/Browser/Bridge/Account/GetAccounts.h b/SpeckleConnector/Connector/Interface/Browser/Bridge/Account/GetAccounts.h index 2f906b4..cc81cd7 100644 --- a/SpeckleConnector/Connector/Interface/Browser/Bridge/Account/GetAccounts.h +++ b/SpeckleConnector/Connector/Interface/Browser/Bridge/Account/GetAccounts.h @@ -21,6 +21,11 @@ namespace connector::interface::browser::bridge { @param bridge The parent bridge object (provides access to bridge methods) */ GetAccounts(); + /*! + Cppy constructor + @param bridge The parent bridge object (provides access to bridge methods) + */ + GetAccounts(const GetAccounts& source) = default; /*! Object cloning diff --git a/SpeckleLib/Speckle/Interface/Browser/Bridge/BrowserBridge.cpp b/SpeckleLib/Speckle/Interface/Browser/Bridge/BrowserBridge.cpp index 4e3861e..3caedc5 100644 --- a/SpeckleLib/Speckle/Interface/Browser/Bridge/BrowserBridge.cpp +++ b/SpeckleLib/Speckle/Interface/Browser/Bridge/BrowserBridge.cpp @@ -5,6 +5,7 @@ #include "Speckle/Interface/Browser/JSPortal.h" #include "Speckle/Interface/Browser/Bridge/Functions/GetBindingsMethodNames.h" #include "Speckle/Interface/Browser/Bridge/Functions/RunMethod.h" +#include "Speckle/Interface/Browser/Bridge/Functions/GetCallResult.h" #include #include @@ -36,6 +37,7 @@ BrowserBridge::BrowserBridge(const String& name) : JSObject{name} { //Populate the required browser bridge functions callable from JS emplace_back(std::make_unique(*this)); emplace_back(std::make_unique(*this)); + emplace_back(std::make_unique(*this)); } //BrowserBridge::BrowserBridge diff --git a/SpeckleLib/Speckle/Interface/Browser/Bridge/BrowserBridge.h b/SpeckleLib/Speckle/Interface/Browser/Bridge/BrowserBridge.h index df4626c..bc977e4 100644 --- a/SpeckleLib/Speckle/Interface/Browser/Bridge/BrowserBridge.h +++ b/SpeckleLib/Speckle/Interface/Browser/Bridge/BrowserBridge.h @@ -64,13 +64,15 @@ namespace speckle::interface::browser::bridge { protected: /*! - Add a browser method name - @tparam T The method type (which also defines the argument type + Add a browser method + @tparam T The method type (which also defines the argument type) */ template requires (std::is_base_of_v) void addMethod() const { //The argument type is registered against the bridge to enable an appropriate object to be deserialised from the JS args - m_methods->emplace(T{}.registerArgument(getName())); + auto method = new T; + method->registerArgument(getName()); + m_methods->insert(m_methods->end(), method); } private: diff --git a/SpeckleLib/Speckle/Interface/Browser/Bridge/Functions/GetCallResult.cpp b/SpeckleLib/Speckle/Interface/Browser/Bridge/Functions/GetCallResult.cpp index f3ecdb3..0e22157 100644 --- a/SpeckleLib/Speckle/Interface/Browser/Bridge/Functions/GetCallResult.cpp +++ b/SpeckleLib/Speckle/Interface/Browser/Bridge/Functions/GetCallResult.cpp @@ -22,6 +22,16 @@ GetCallResult::GetCallResult(BrowserBridge& bridge) : m_bridge{bridge}, } //GetCallResult::GetCallResult +/*-------------------------------------------------------------------- + Get an argument instance for the function (used to deserialise/unpack incoming arguments) + + return: An argument instance + --------------------------------------------------------------------*/ +std::unique_ptr GetCallResult::getArgument() const { + return std::make_unique(); +} //GetCallResult::getArgument + + /*-------------------------------------------------------------------- Get the result for a specified call diff --git a/SpeckleLib/Speckle/Interface/Browser/Bridge/JSBridgeMethod.h b/SpeckleLib/Speckle/Interface/Browser/Bridge/JSBridgeMethod.h index 9f06901..b148f83 100644 --- a/SpeckleLib/Speckle/Interface/Browser/Bridge/JSBridgeMethod.h +++ b/SpeckleLib/Speckle/Interface/Browser/Bridge/JSBridgeMethod.h @@ -23,7 +23,7 @@ namespace speckle::interface::browser::bridge { @tparam Return The function return type */ template - class JSBridgeMethod : public NamedFunction, public JSBridgeMethodBase { + class JSBridgeMethod : public NamedFunction, public virtual JSBridgeMethodBase { public: // MARK: - Types @@ -45,6 +45,11 @@ namespace speckle::interface::browser::bridge { @param source The object to copy */ JSBridgeMethod(const JSBridgeMethod& source) = default; + /*! + Object cloning + @return A clone of this object + */ + JSBridgeMethod* clonePtr() const override = 0; // MARK: - Functions (const) @@ -53,7 +58,7 @@ namespace speckle::interface::browser::bridge { @param bridge The target bridge name @return A reference to this */ - JSBridgeMethodBase& registerArgument(const speckle::utility::String& bridge) override { + JSBridgeMethod& registerArgument(const speckle::utility::String& bridge) override { if constexpr(!std::same_as) JSBridgeArgumentWrap::defineArgument(bridge, base::getName()); return *this;