In my host app I have simple ostream'like object with metods, returning reference for self, for chaining methods.
For example
class MyBuffer {
MyBuffer& operator<<(const string& s) {
...
return *this;
}
MyBuffer& operator<<(int i) {
...
return *this;
}
};
I register it as RegisterObjectMethod("MyBuffer", "MyBuffer& opShl(const string&in)"....
and so on.
Another object has member with type MyBuffer.
For example,
class Responce {
....
MyBuffer body;
....
In script I write function which I call from app:
void handler(Responce@ res) {
res.body << "Hello " << 1 << " world!"
}
But even in for first call for string "Hello" - AngelScript attemp create temp copy of MyBuffer and call method of temp var instead of real object.
asEP_ALLOW_UNSAFE_REFERENCES is on.
How I can implement chainig of methods call?