Extern support for creating userdata collections

This commit is contained in:
Deukhoofd 2019-08-15 15:01:27 +02:00
parent 5b3bc26bdb
commit 8e64da15a0
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
2 changed files with 19 additions and 0 deletions

View File

@ -33,6 +33,11 @@ namespace Porygon::UserData {
return make_shared<UserDataCollectionType>(nullptr, valueType, false, true); return make_shared<UserDataCollectionType>(nullptr, valueType, false, true);
} }
static UserDataCollectionType * CreateIterable(const ScriptType* valueType){
return new UserDataCollectionType(nullptr, shared_ptr<const ScriptType>(valueType),
false, true);
}
bool CanBeIndexedWith(const ScriptType* indexer) const final{ bool CanBeIndexedWith(const ScriptType* indexer) const final{
if (!_indexable){ if (!_indexable){
return false; return false;

View File

@ -1 +1,15 @@
#include "UserDataCollectionValue.hpp" #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));
}
}
}