Set the correct JS object name for AccountsBridge
Added GetAccounts method to AccountsBridge Added GetCallResult function to BrowserBridge Fix to BrowserBridge::addMethod Other minor template fixes
This commit is contained in:
@@ -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<GetAccounts>();
|
||||
} //AccountBridge::AccountBridge
|
||||
|
||||
@@ -17,6 +17,7 @@ namespace connector::interface::browser::bridge {
|
||||
|
||||
// MARK: - Constructors
|
||||
|
||||
using base::base;
|
||||
/*!
|
||||
Default constructor
|
||||
*/
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 <algorithm>
|
||||
#include <map>
|
||||
@@ -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<GetBindingsMethodNames>(*this));
|
||||
emplace_back(std::make_unique<RunMethod>(*this));
|
||||
emplace_back(std::make_unique<GetCallResult>(*this));
|
||||
} //BrowserBridge::BrowserBridge
|
||||
|
||||
|
||||
|
||||
@@ -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<typename T> requires (std::is_base_of_v<JSBridgeMethodBase, T>)
|
||||
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:
|
||||
|
||||
@@ -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<active::serialise::Cargo> GetCallResult::getArgument() const {
|
||||
return std::make_unique<JSBridgeArgument>();
|
||||
} //GetCallResult::getArgument
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------
|
||||
Get the result for a specified call
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace speckle::interface::browser::bridge {
|
||||
@tparam Return The function return type
|
||||
*/
|
||||
template<typename Argument, typename Return>
|
||||
class JSBridgeMethod : public NamedFunction<Argument, Return>, public JSBridgeMethodBase {
|
||||
class JSBridgeMethod : public NamedFunction<Argument, Return>, 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<Argument, void>)
|
||||
JSBridgeArgumentWrap::defineArgument<Argument>(bridge, base::getName());
|
||||
return *this;
|
||||
|
||||
Reference in New Issue
Block a user