Fixed error string from userdata return values not persisting long enough.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2019-09-28 13:35:32 +02:00
parent f8cbe502c9
commit a32b76d904
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
2 changed files with 7 additions and 3 deletions

View File

@ -6,7 +6,7 @@ extern "C"{
}
Porygon::UserData::UserDataReturnValue* ErrorValue(const char* message){
return new Porygon::UserData::UserDataReturnValue(message);
return new Porygon::UserData::UserDataReturnValue(string(message));
}
}

View File

@ -8,13 +8,17 @@ namespace Porygon::UserData {
struct UserDataReturnValue {
bool _success;
union {
const char *_message;
string _message;
const Evaluation::EvalValue *_value;
};
public:
UserDataReturnValue(Evaluation::EvalValue *value) : _success(true), _value(value) {}
UserDataReturnValue(const Evaluation::EvalValue *value) : _success(true), _value(value) {}
UserDataReturnValue(const char *message) : _success(false), _message(message) {}
UserDataReturnValue(string message) : _success(false), _message(message) {}
~UserDataReturnValue(){
}
inline const Evaluation::EvalValue *Evaluate() const{
if (_success) {