I am starting with C++/CLI combined with IronPython :) I ran into problem with managed structures in Python code. My structure looks like this
[System::Runtime::InteropServices::StructLayout(
System::Runtime::InteropServices::LayoutKind::Sequential)]
public value struct VersionInfo
{
[System::Runtime::InteropServices::MarshalAsAttribute(
System::Runtime::InteropServices::UnmanagedType::U4)]
DWORD Major;
};
Passing this structure to Python is as follows
VersionInfo^ vi = gcnew VersionInfo();
vi->Major = 12345;
IronPython::Runtime::PythonFunction^ function =
(IronPython::Runtime::PythonFunction^)
m_PluginScope->GetVariable("GetGlobalInfo");
array<VersionInfo^>^ args = gcnew array<VersionInfo^>(1)
{
vi
};
auto result = m_Engine->Operations->Invoke(function, args);
And finally, the Python code:
def GetGlobalInfo(info):
info.Major = 55
return info.Major
The return value in result is not 55 as expected, but 12345. Can anybody please help me to find out, why the value is not changed from Python code? Thanks