diff --git a/src/UserData/UserDataCollections/UserDataCollectionType.hpp b/src/UserData/UserDataCollections/UserDataCollectionType.hpp index 6f12ed2..da4271b 100644 --- a/src/UserData/UserDataCollections/UserDataCollectionType.hpp +++ b/src/UserData/UserDataCollections/UserDataCollectionType.hpp @@ -33,6 +33,11 @@ namespace Porygon::UserData { return make_shared(nullptr, valueType, false, true); } + static UserDataCollectionType * CreateIterable(const ScriptType* valueType){ + return new UserDataCollectionType(nullptr, shared_ptr(valueType), + false, true); + } + bool CanBeIndexedWith(const ScriptType* indexer) const final{ if (!_indexable){ return false; diff --git a/src/UserData/UserDataCollections/UserDataCollectionValue.cpp b/src/UserData/UserDataCollections/UserDataCollectionValue.cpp index 3aa1873..9d61a3a 100644 --- a/src/UserData/UserDataCollections/UserDataCollectionValue.cpp +++ b/src/UserData/UserDataCollections/UserDataCollectionValue.cpp @@ -1 +1,15 @@ #include "UserDataCollectionValue.hpp" + +namespace Porygon::UserData{ +extern "C" { +UserDataCollectionType* CreateCollectionType(const ScriptType* keyType, const ScriptType* valueType){ + return UserDataCollectionType::CreateIndexable(keyType, valueType); +} +UserDataCollectionValue* CreateCollectionValue(UserDataCollectionType* type, void* obj, + const EvalValue* (*get)(void*, const EvalValue*), + void (*set)(void*, const EvalValue*, const EvalValue*), + Iterator* (*getIterator)(void*)){ + return new UserDataCollectionValue(type, new UserDataCollectionHelper(obj, get, set, getIterator)); +} +} +}