2019-06-21 15:03:13 +00:00
|
|
|
#ifndef PORYGONLANG_USERDATAFUNCTIONTYPE_HPP
|
|
|
|
#define PORYGONLANG_USERDATAFUNCTIONTYPE_HPP
|
|
|
|
|
|
|
|
#include <utility>
|
2019-07-28 10:58:38 +00:00
|
|
|
#include "../ScriptTypes/ScriptType.hpp"
|
|
|
|
#include "../ScriptTypes/FunctionScriptType.hpp"
|
2019-06-21 15:03:13 +00:00
|
|
|
|
|
|
|
namespace Porygon::UserData{
|
2019-06-29 17:59:42 +00:00
|
|
|
class UserDataFunctionOption : public GenericFunctionOption{
|
2019-06-21 15:03:13 +00:00
|
|
|
public:
|
2019-09-01 13:35:45 +00:00
|
|
|
UserDataFunctionOption(std::shared_ptr<const ScriptType> returnType, vector<shared_ptr<const ScriptType>> parameterTypes)
|
2019-06-29 17:59:42 +00:00
|
|
|
: GenericFunctionOption(std::move(returnType), std::move(parameterTypes)) {
|
2019-06-21 15:03:13 +00:00
|
|
|
|
|
|
|
}
|
2019-09-15 11:08:11 +00:00
|
|
|
static UserDataFunctionOption* FromRawPointers(ScriptType* returnType, vector<ScriptType*> parameterTypes){
|
2019-09-01 13:35:45 +00:00
|
|
|
auto rt = shared_ptr<const ScriptType>(returnType);
|
|
|
|
auto p = vector<shared_ptr<const ScriptType>>(parameterTypes.size());
|
2019-07-25 15:23:54 +00:00
|
|
|
for (size_t i = 0; i < parameterTypes.size(); i++){
|
2019-09-15 11:08:11 +00:00
|
|
|
p[i] = shared_ptr<ScriptType>(parameterTypes[i]);
|
2019-06-28 15:02:38 +00:00
|
|
|
}
|
2019-06-29 17:59:42 +00:00
|
|
|
return new UserDataFunctionOption(rt, p);
|
2019-06-28 15:02:38 +00:00
|
|
|
}
|
|
|
|
|
2019-07-04 17:08:13 +00:00
|
|
|
inline static UserDataFunctionOption* FromRawPointers(ScriptType* returnType){
|
2019-06-28 15:02:38 +00:00
|
|
|
auto rt = shared_ptr<ScriptType>(returnType);
|
2019-06-29 17:59:42 +00:00
|
|
|
return new UserDataFunctionOption(rt, {});
|
2019-06-28 15:02:38 +00:00
|
|
|
}
|
|
|
|
|
2019-07-25 15:23:54 +00:00
|
|
|
[[nodiscard]] inline bool IsScriptFunction() const final{
|
2019-06-21 15:03:13 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif //PORYGONLANG_USERDATAFUNCTIONTYPE_HPP
|