Ok its reproduced, it was easier than I thought.
Here is link to the cpp file and a compiled plugin DLL:
https://sky.einhugur.com:4433/owncloud/index.php/s/oVliji1FuBRrcCi
The actual code:
#ifdef _MSC_VER
#include “winheader++.h”
#endif
#include “rb_plugin.h”
REALstring EFormat(double value, REALstring format)
{
static REALstring(_format)(double, REALstring) = nil;
if (!_format)
_format = (REALstring()(double, REALstring)) REALLoadFrameworkMethod(“Format(value as Double, format as String) as String”);
return _format(value, format);
}
static REALstring TestFunction(REALobject instance)
{
REALstring formatMask = REALBuildStringWithEncoding("#.##", 3, kREALTextEncodingASCII);
REALstring symbol = REALBuildStringWithEncoding(",", 1, kREALTextEncodingASCII);
REALstring someString = EFormat(179.20f, formatMask);
// For the purpose of this test we are not unlocking anything, that might crash anyhow since memory is clobbered at this point.
return symbol; // Expected here is "," but I actually get "179.2"
}
struct TestData
{
void* NoData;
};
REALmethodDefinition TestClassMethods[1] = {
{ (REALproc)TestFunction, REALnoImplementation, “MyTestFunction() as String”,REALconsoleSafe },
};
REALclassDefinition TestClass = {
kCurrentREALControlVersion, // Version
“TestClass”, // Name
nil, // Super Name
sizeof(TestData), // Data size
0, // Something for system use
nil, // Constructor index
nil, // Destructor Index
nil, // Pointer to property def
0, // Property count
TestClassMethods, // Pointer to method def
1, // Method count
nil, // Pointer to Event def
0, // event Count
nil, // *eventInstances
};
void PluginEntry(void)
{
SetClassConsoleSafe(&TestClass);
REALRegisterClass(&TestClass);
}
And code to test it in Xojo is:
Dim test as TestClass = new TestClass()
MsgBox test.MyTestFunction()
Expected result is “,” but result we get is “179.2”