Make a lot of one-liner functions inline
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2019-07-04 19:08:13 +02:00
parent bb0a6aba19
commit 32836c6c58
53 changed files with 428 additions and 424 deletions

View File

@@ -52,19 +52,19 @@ namespace Porygon::UserData {
delete _concatenation;
}
bool ContainsField(uint32_t fieldId) const{
inline bool ContainsField(uint32_t fieldId) const{
return _fields.find(fieldId) != _fields.end();
}
UserDataField *GetField(uint32_t fieldId) const {
inline UserDataField *GetField(uint32_t fieldId) const {
return _fields.at(fieldId);
}
void CreateField(uint32_t fieldId, UserDataField *field) {
inline void CreateField(uint32_t fieldId, UserDataField *field) {
_fields.insert({fieldId, field});
}
int32_t GetFieldCount() const{
inline int32_t GetFieldCount() const{
return _fields.size();
}

View File

@@ -16,23 +16,23 @@ namespace Porygon::UserData{
: _type(shared_ptr<ScriptType>(type)), _get(getter), _set(setter){
}
shared_ptr<ScriptType> GetType(){
inline shared_ptr<ScriptType> GetType(){
return _type;
}
bool HasGetter(){
inline bool HasGetter(){
return _get != nullptr;
}
Evaluation::EvalValue* Get(void* obj){
inline Evaluation::EvalValue* Get(void* obj){
return this ->_get(obj);
}
bool HasSetter(){
inline bool HasSetter(){
return _set != nullptr;
}
void Set(void* obj, Evaluation::EvalValue* val){
inline void Set(void* obj, Evaluation::EvalValue* val){
this->_set(obj, val);
}
};

View File

@@ -27,7 +27,7 @@ namespace Porygon::UserData{
}
Evaluation::EvalValue* Call(Evaluation::EvalValue* parameters[], int parameterCount){
inline Evaluation::EvalValue* Call(Evaluation::EvalValue* parameters[], int parameterCount){
return _call(_obj, parameters, parameterCount);
}
};

View File

@@ -21,7 +21,7 @@ namespace Porygon::UserData{
return new UserDataFunctionOption(rt, p);
}
static UserDataFunctionOption* FromRawPointers(ScriptType* returnType){
inline static UserDataFunctionOption* FromRawPointers(ScriptType* returnType){
auto rt = shared_ptr<ScriptType>(returnType);
return new UserDataFunctionOption(rt, {});
}
@@ -29,7 +29,7 @@ namespace Porygon::UserData{
const bool IsScriptFunction() const final{
inline const bool IsScriptFunction() const final{
return false;
}
};

View File

@@ -23,11 +23,11 @@ namespace Porygon::UserData {
return _func(_parent, b);
}
const shared_ptr<ScriptType> GetSecondParameterType() const{
inline const shared_ptr<ScriptType> GetSecondParameterType() const{
return _secondParameter;
}
const shared_ptr<ScriptType> GetReturnType() const{
inline const shared_ptr<ScriptType> GetReturnType() const{
return _returnType;
}
};

View File

@@ -30,11 +30,11 @@ namespace Porygon::UserData {
return _userData->ContainsField(str->GetHashValue());
}
const bool CanBeIndexedWithIdentifier(uint32_t hash) const final {
inline const bool CanBeIndexedWithIdentifier(uint32_t hash) const final {
return _userData -> ContainsField(hash);
}
UserDataField *GetField(uint32_t id) {
inline UserDataField *GetField(uint32_t id) {
return _userData->GetField(id);
}
@@ -46,7 +46,7 @@ namespace Porygon::UserData {
throw "TODO: indexing with dynamic keys";
}
const shared_ptr<ScriptType> GetIndexedType(uint32_t hash) const final {
inline const shared_ptr<ScriptType> GetIndexedType(uint32_t hash) const final {
return _userData->GetField(hash)->GetType();
}
};

View File

@@ -43,11 +43,11 @@ namespace Porygon::UserData {
_internal._userData.clear();
}
static bool HasUserDataType(uint32_t i) {
inline static bool HasUserDataType(uint32_t i) {
return UserDataStorage::_internal._userData.find(i) != UserDataStorage::_internal._userData.end();
}
static UserData* GetUserDataType(uint32_t i) {
inline static UserData* GetUserDataType(uint32_t i) {
return UserDataStorage::_internal._userData[i];
}
};

View File

@@ -22,7 +22,7 @@ namespace Porygon::UserData {
_obj = obj;
}
const TypeClass GetTypeClass() const final {
inline const TypeClass GetTypeClass() const final {
return TypeClass::UserData;
}
@@ -32,11 +32,11 @@ namespace Porygon::UserData {
return _obj == ((UserDataValue *) b)->_obj;
}
const shared_ptr<EvalValue> Clone() const final {
inline const shared_ptr<EvalValue> Clone() const final {
return make_shared<UserDataValue>(_userData, _obj);
}
const std::size_t GetHashCode() const final {
inline const std::size_t GetHashCode() const final {
return reinterpret_cast<intptr_t>(_obj);
}
@@ -46,7 +46,7 @@ namespace Porygon::UserData {
return shared_ptr<EvalValue>(field->Get(_obj));
}
const shared_ptr<EvalValue> IndexValue(uint32_t hash) const final {
inline const shared_ptr<EvalValue> IndexValue(uint32_t hash) const final {
auto field = _userData->GetField(hash);
return shared_ptr<EvalValue>(field->Get(_obj));
}
@@ -57,7 +57,7 @@ namespace Porygon::UserData {
field->Set(_obj, value.get());
}
void* GetObjectPointer(){
inline void* GetObjectPointer(){
return _obj;
}
};