Skip to content

Commit 06d7a72

Browse files
author
Helge Mathee
committed
allow to construct interface rt vals
1 parent b6a5b6b commit 06d7a72

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

Diff for: DGGraphImpl.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -2359,7 +2359,7 @@ void DGGraphImpl::getDGPortInfo(FabricCore::Variant & portInfo, FabricCore::RTVa
23592359
{
23602360
if(!rtVal.isNullObject())
23612361
{
2362-
FabricCore::RTVal persistable = FabricSplice::constructObjectRTVal("Persistable", 1, &rtVal);
2362+
FabricCore::RTVal persistable = FabricSplice::constructInterfaceRTVal("Persistable", rtVal);
23632363
if(!persistable.isNullObject())
23642364
{
23652365
try
@@ -2369,7 +2369,8 @@ void DGGraphImpl::getDGPortInfo(FabricCore::Variant & portInfo, FabricCore::RTVa
23692369
}
23702370
catch(FabricCore::Exception e)
23712371
{
2372-
LoggingImpl::reportError(e.getDesc_cstr());
2372+
//ignore errors, assume we couldn't cast.
2373+
//LoggingImpl::reportError(e.getDesc_cstr());
23732374
}
23742375
}
23752376
}
@@ -2682,7 +2683,7 @@ bool DGGraphImpl::setFromPersistenceDataDict(
26822683
FabricCore::RTVal memberRTVal = dgNode.getMemberSliceValue(valueMemberVar->getStringData(), 0);
26832684
if(memberRTVal.isValid() && !memberRTVal.isNullObject())
26842685
{
2685-
FabricCore::RTVal persistable = FabricSplice::constructObjectRTVal("Persistable", 1, &memberRTVal);
2686+
FabricCore::RTVal persistable = FabricSplice::constructInterfaceRTVal("Persistable", memberRTVal);
26862687
if(!persistable.isNullObject())
26872688
{
26882689
try

Diff for: FabricSplice.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,21 @@ void FECS_ConstructObjectRTValArgs(FabricCore::RTVal & result, const char * rt,
190190
FECS_CATCH_VOID
191191
}
192192

193+
void FECS_ConstructInterfaceRTValArgs(FabricCore::RTVal & result, const char * rt, const FabricCore::RTVal & object)
194+
{
195+
FECS_TRY_CLEARERROR
196+
const FabricCore::Client * client = DGGraphImpl::getClient();
197+
if(client == NULL)
198+
return;
199+
200+
const char * realExtName = FabricCore::GetRegisteredTypeExtName(*client, rt);
201+
if(realExtName != NULL)
202+
DGGraphImpl::loadExtension(realExtName);
203+
204+
result = FabricCore::RTVal::Construct(*client, rt, 1, &object);
205+
FECS_CATCH_VOID
206+
}
207+
193208
void FECS_ConstructBooleanRTVal(FabricCore::RTVal & result, bool value)
194209
{
195210
FECS_TRY_CLEARERROR

Diff for: FabricSplice.h

+13
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@ The SPLICECAPI provides several global functions. These can be used to initializ
180180
// creates a RTVal given a KL object name and construction args
181181
FabricCore::RTVal constructObjectRTVal(const char * rt, uint32_t nbArgs, const FabricCore::RTVal * args);
182182
183+
// creates a KL interface RTVal given a KL object to cast
184+
FabricCore::RTVal constructInterfaceRTVal(const char * rt, const FabricCore::RTVal & object);
185+
183186
// creates a Boolean RTVal given its value
184187
FabricCore::RTVal constructBooleanRTVal(bool value);
185188
@@ -1701,6 +1704,7 @@ FECS_DECL void FECS_ConstructRTVal(FabricCore::RTVal & result, const char * rt);
17011704
FECS_DECL void FECS_ConstructRTValArgs(FabricCore::RTVal & result, const char * rt, uint32_t nbArgs, const FabricCore::RTVal * args);
17021705
FECS_DECL void FECS_ConstructObjectRTVal(FabricCore::RTVal & result, const char * rt);
17031706
FECS_DECL void FECS_ConstructObjectRTValArgs(FabricCore::RTVal & result, const char * rt, uint32_t nbArgs, const FabricCore::RTVal * args);
1707+
FECS_DECL void FECS_ConstructInterfaceRTValArgs(FabricCore::RTVal & result, const char * rt, const FabricCore::RTVal & object);
17041708
FECS_DECL void FECS_ConstructBooleanRTVal(FabricCore::RTVal & result, bool value);
17051709
FECS_DECL void FECS_ConstructSInt8RTVal(FabricCore::RTVal & result, int8_t value);
17061710
FECS_DECL void FECS_ConstructSInt16RTVal(FabricCore::RTVal & result, int16_t value);
@@ -2112,6 +2116,15 @@ namespace FabricSplice
21122116
return result;
21132117
}
21142118

2119+
// creates a KL interface RTVal given a KL object to cast
2120+
inline FabricCore::RTVal constructInterfaceRTVal(const char * rt, const FabricCore::RTVal & object)
2121+
{
2122+
FabricCore::RTVal result;
2123+
FECS_ConstructInterfaceRTValArgs(result, rt, object);
2124+
Exception::MaybeThrow();
2125+
return result;
2126+
}
2127+
21152128
// creates a Boolean RTVal given its value
21162129
inline FabricCore::RTVal constructBooleanRTVal(bool value)
21172130
{

0 commit comments

Comments
 (0)