Support sir import of hints and restrictions
parent
4ec4927156
commit
938e9d9368
|
@ -11,38 +11,24 @@ interface Annotations {
|
||||||
/**
|
/**
|
||||||
* A hint including name and parsed arguments
|
* A hint including name and parsed arguments
|
||||||
*/
|
*/
|
||||||
@abstract
|
|
||||||
Hint {
|
Hint {
|
||||||
string name;
|
string name;
|
||||||
}
|
|
||||||
|
|
||||||
HintValues extends Hint {
|
|
||||||
/**
|
/**
|
||||||
* if a string has arguments at all, they are stored as plain text
|
* if a string has arguments at all, they are stored as plain text
|
||||||
*/
|
*/
|
||||||
string[] arguments;
|
string[] arguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
HintTypes extends Hint {
|
|
||||||
Type[] types;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base of type and field restrictions.
|
* Base of type and field restrictions.
|
||||||
*/
|
*/
|
||||||
@abstract
|
|
||||||
Restriction {
|
Restriction {
|
||||||
string name;
|
string name;
|
||||||
}
|
|
||||||
|
|
||||||
RestrictionValues extends Restriction {
|
|
||||||
/**
|
/**
|
||||||
* restriction arguments are stored as strings, because I do not want
|
* restriction arguments are stored as strings, because I do not want
|
||||||
* to introduce a million restriction types just for range restrictions.
|
* to introduce a million restriction types just for range restrictions.
|
||||||
*/
|
*/
|
||||||
string[] arguments;
|
string[] arguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
RestrictionTypes extends Restriction {
|
|
||||||
Type[] types;
|
|
||||||
}
|
|
|
@ -61,6 +61,8 @@ inline std::unique_ptr<sirEdit::data::TypeWithFields> _loadFields(SOURCE* source
|
||||||
inline sirEdit::data::Type* genBaseType(sir::UserdefinedType& uf) {
|
inline sirEdit::data::Type* genBaseType(sir::UserdefinedType& uf) {
|
||||||
std::string skillType = uf.skillName();
|
std::string skillType = uf.skillName();
|
||||||
sirEdit::data::Type* result;
|
sirEdit::data::Type* result;
|
||||||
|
|
||||||
|
// Create type
|
||||||
if(skillType == sir::ClassType::typeName) {
|
if(skillType == sir::ClassType::typeName) {
|
||||||
std::unique_ptr<sirEdit::data::TypeWithFields> fields = std::move(_loadFields(static_cast<sir::ClassType*>(&uf)));
|
std::unique_ptr<sirEdit::data::TypeWithFields> fields = std::move(_loadFields(static_cast<sir::ClassType*>(&uf)));
|
||||||
result = new TypeClass(std::move(*(fields.get())), std::vector<sirEdit::data::TypeInterface*>(), nullptr);
|
result = new TypeClass(std::move(*(fields.get())), std::vector<sirEdit::data::TypeInterface*>(), nullptr);
|
||||||
|
@ -71,6 +73,26 @@ inline sirEdit::data::Type* genBaseType(sir::UserdefinedType& uf) {
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw std::invalid_argument(std::string("Unknown skill class type ") + skillType);
|
throw std::invalid_argument(std::string("Unknown skill class type ") + skillType);
|
||||||
|
|
||||||
|
// Hints
|
||||||
|
if(uf.getHints() != nullptr)
|
||||||
|
for(auto& i : *(uf.getHints())) {
|
||||||
|
auto tmp = result->getHints().find(*(i->getName()));
|
||||||
|
if(tmp == result->getHints().end())
|
||||||
|
tmp = result->getHints().insert(make_pair(string(*(i->getName())), vector<string>())).first;
|
||||||
|
for(auto& j : *(i->getArguments()))
|
||||||
|
tmp->second.push_back(*j);
|
||||||
|
|
||||||
|
}
|
||||||
|
if(uf.getRestrictions() != nullptr)
|
||||||
|
for(auto& i : *(uf.getRestrictions())) {
|
||||||
|
auto tmp = result->getRestrictions().find(*(i->getName()));
|
||||||
|
if(tmp == result->getRestrictions().end())
|
||||||
|
tmp = result->getRestrictions().insert(make_pair(string(*(i->getName())), vector<string>())).first;
|
||||||
|
for(auto& j : *(i->getArguments()))
|
||||||
|
tmp->second.push_back(*j);
|
||||||
|
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue