Autodesk / Autodesk/AutomaticComponentToolkit

[C++] Interfacewrapper.cpp compilation failure (string cache)

Open
#148 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
53
Forks
26
PR merge metrics
No merged PRs in 30d

Description

Given a function with a class / optionalclass argument, the generated code ends up looking something like this:

interfacewrapper.cpp
```c++
std::string sName("");
IBase* pBaseThisResult(nullptr);
IFoo* pIFoo = dynamic_cast(pIBaseClass);
if (!pIFoo)
throw EMyComponentInterfaceException(MYCOMPONENT_ERROR_INVALIDCAST);
bool isCacheCall = (pNameBuffer == nullptr);
if (isCacheCall) {
pBaseThisResult = pIFoo->GetProperties(sName, *pBar);
pIFoo->_setCache (new ParameterCache_3 (sName, *pBar, pBaseThisResult));
}
else {
auto cache = dynamic_cast*> (pIFoo->_getCache ());
if (cache == nullptr)
throw EMyComponentInterfaceException(MYCOMPONENT_ERROR_INVALIDCAST);
cache->retrieveData (sName, *pBar, pBaseThisResult);
pIFoo->_setCache (nullptr);
}
```

Since ` CMyComponentFoo` is a binding class, this won't compile. Also, the pointer `pBaseThisResult` is actually of type `IBase *`.

I've hacked a fix to get it to work by generating `IBase *` instead, but as I don't know how this parameter caching is supposed to work I can't say if it's the right way to fix it.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.