Skip to content

Commit

Permalink
Migrated LuaFBs to new GenericFB template
Browse files Browse the repository at this point in the history
In oder that the lua fbs are correctly creating their interface they
need to use the GenericFB infrastructure.
  • Loading branch information
azoitl committed Jun 13, 2024
1 parent 5a42df2 commit c58dca0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/core/lua/luabfb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const char CLuaBFB::LUA_NAME[] = "FORTE_CLuaFB";
const luaL_Reg CLuaBFB::LUA_FUNCS[] = { { "__index", CLuaFB_index }, { "__newindex", CLuaFB_newindex }, { "__call", CLuaFB_call }, { nullptr, nullptr } };

CLuaBFB::CLuaBFB(CStringDictionary::TStringId paInstanceNameId, const CLuaBFBTypeEntry* paTypeEntry, forte::core::CFBContainer &paContainer) :
CBasicFB(paContainer, paTypeEntry->getInterfaceSpec(), paInstanceNameId, paTypeEntry->getInternalVarsInformation()),
CGenFunctionBlock<CBasicFB>(paContainer, paTypeEntry->getInterfaceSpec(), paInstanceNameId, paTypeEntry->getInternalVarsInformation()),
mTypeEntry(paTypeEntry) {
CLuaEngine *luaEngine = getResource()->getLuaEngine();
luaEngine->registerType<CLuaBFB>();
Expand All @@ -67,7 +67,7 @@ CLuaBFB::~CLuaBFB() = default;
bool CLuaBFB::initialize() {
//before calling super we need to configure the interface of the FB
setupFBInterface(getFBInterfaceSpec());
return CBasicFB::initialize();
return CGenFunctionBlock<CBasicFB>::initialize();
}

void CLuaBFB::executeEvent(TEventID paEIID, CEventChainExecutionThread *paECET) {
Expand Down
8 changes: 7 additions & 1 deletion src/core/lua/luabfb.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#ifndef SRC_CORE_LUABFB_H_
#define SRC_CORE_LUABFB_H_

#include "genfb.h"
#include "basicfb.h"
#include "luabfbtypeentry.h"

Expand All @@ -28,7 +29,7 @@ extern "C" {
int CLuaFB_call(lua_State *luaState);
}

class CLuaBFB : public CBasicFB {
class CLuaBFB : public CGenFunctionBlock<CBasicFB> {
private:
static constexpr TForteUInt32 scmLuaFBVarMax = 65535;
static constexpr TForteUInt32 scmLuaAdpVarMax = 255;
Expand Down Expand Up @@ -57,6 +58,11 @@ class CLuaBFB : public CBasicFB {

bool initialize() override;

bool createInterfaceSpec(const char *paConfigString, SFBInterfaceSpec &paInterfaceSpec) override {
paInterfaceSpec = *mInterfaceSpec;
return true;
}

void executeEvent(TEventID paEIID, CEventChainExecutionThread *paECET) override;

CStringDictionary::TStringId getFBTypeId() const override {
Expand Down
4 changes: 2 additions & 2 deletions src/core/lua/luacfb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "criticalregion.h"

CLuaCFB::CLuaCFB(CStringDictionary::TStringId paInstanceNameId, const CLuaCFBTypeEntry* paTypeEntry, SCFB_FBNData &paFbnData, forte::core::CFBContainer &paContainer) :
CCompositeFB(paContainer, paTypeEntry->getInterfaceSpec(), paInstanceNameId, paFbnData), mTypeEntry(paTypeEntry) {
CGenFunctionBlock<CCompositeFB>(paContainer, paTypeEntry->getInterfaceSpec(), paInstanceNameId, paFbnData), mTypeEntry(paTypeEntry) {
}

CLuaCFB::~CLuaCFB() = default;
Expand All @@ -26,7 +26,7 @@ CLuaCFB::~CLuaCFB() = default;
bool CLuaCFB::initialize() {
//before calling super we need to configure the interface of the FB
setupFBInterface(getFBInterfaceSpec());
return CCompositeFB::initialize();
return CGenFunctionBlock<CCompositeFB>::initialize();
}

void CLuaCFB::readInputData(TEventID paEIID) {
Expand Down
8 changes: 7 additions & 1 deletion src/core/lua/luacfb.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
#ifndef SRC_CORE_LUACFB_H_
#define SRC_CORE_LUACFB_H_

#include "genfb.h"
#include "cfb.h"
#include "luacfbtypeentry.h"

class CLuaCFB : public CCompositeFB {
class CLuaCFB : public CGenFunctionBlock<CCompositeFB> {
public:
CLuaCFB(CStringDictionary::TStringId paInstanceNameId, const CLuaCFBTypeEntry* paTypeEntry, SCFB_FBNData &paFbnData, forte::core::CFBContainer &paContainer);
~CLuaCFB() override;
Expand All @@ -29,6 +30,11 @@ class CLuaCFB : public CCompositeFB {

bool initialize() override;

bool createInterfaceSpec(const char *paConfigString, SFBInterfaceSpec &paInterfaceSpec) override {
paInterfaceSpec = *mInterfaceSpec;
return true;
}

protected:
virtual void readInternal2InterfaceOutputData(TEventID paEOID);

Expand Down

0 comments on commit c58dca0

Please sign in to comment.