Fix docker
This commit is contained in:
@ -2,36 +2,112 @@
|
||||
|
||||
namespace Tesses::CrossLang
|
||||
{
|
||||
|
||||
TObject Dictionary_Items(GCList& ls, std::vector<TObject> args)
|
||||
{
|
||||
|
||||
TDictionary* dict;
|
||||
|
||||
if(args.size() == 1 && std::holds_alternative<THeapObjectHolder>(args[0]))
|
||||
TDynamicDictionary* dynDict;
|
||||
if(GetArgumentHeap(args,0,dynDict))
|
||||
{
|
||||
auto item = dynamic_cast<TDictionary*>(std::get<THeapObjectHolder>(args[0]).obj);
|
||||
if(item != nullptr)
|
||||
{
|
||||
TDictionary* enumerableItem = TDictionary::Create(ls);
|
||||
ls.GetGC()->BarrierBegin();
|
||||
TDictionary* enumerableItem = TDictionary::Create(ls);
|
||||
ls.GetGC()->BarrierBegin();
|
||||
|
||||
auto fn = TExternalMethod::Create(ls,"Get Enumerator for Dictionary",{"dict"},[item](GCList& ls2, std::vector<TObject> args)->TObject {
|
||||
return TDictionaryEnumerator::Create(ls2,item);
|
||||
});
|
||||
fn->watch.push_back(item);
|
||||
auto fn = TExternalMethod::Create(ls,"Get Enumerator for Dictionary",{"dict"},[dynDict](GCList& ls2, std::vector<TObject> args)->TObject {
|
||||
return dynDict->GetEnumerator(ls2);
|
||||
});
|
||||
fn->watch.push_back(dynDict);
|
||||
|
||||
enumerableItem->SetValue("GetEnumerator", fn);
|
||||
enumerableItem->SetValue("GetEnumerator", fn);
|
||||
|
||||
ls.GetGC()->BarrierEnd();
|
||||
ls.GetGC()->BarrierEnd();
|
||||
|
||||
return enumerableItem;
|
||||
}
|
||||
return enumerableItem;
|
||||
|
||||
}
|
||||
if(GetArgumentHeap(args,0,dict))
|
||||
{
|
||||
TDictionary* enumerableItem = TDictionary::Create(ls);
|
||||
ls.GetGC()->BarrierBegin();
|
||||
|
||||
auto fn = TExternalMethod::Create(ls,"Get Enumerator for Dictionary",{"dict"},[dict](GCList& ls2, std::vector<TObject> args)->TObject {
|
||||
return TDictionaryEnumerator::Create(ls2,dict);
|
||||
});
|
||||
fn->watch.push_back(dict);
|
||||
|
||||
enumerableItem->SetValue("GetEnumerator", fn);
|
||||
|
||||
ls.GetGC()->BarrierEnd();
|
||||
|
||||
return enumerableItem;
|
||||
|
||||
}
|
||||
|
||||
return Undefined();
|
||||
}
|
||||
|
||||
TObject Dictionary_GetField(GCList& ls, std::vector<TObject> args)
|
||||
{
|
||||
TDictionary* dict;
|
||||
TDynamicDictionary* dynDict;
|
||||
std::string key;
|
||||
if(GetArgument(args,1,key))
|
||||
{
|
||||
if(GetArgumentHeap(args,0,dict))
|
||||
{
|
||||
ls.GetGC()->BarrierBegin();
|
||||
auto res = dict->GetValue(key);
|
||||
ls.GetGC()->BarrierEnd();
|
||||
return res;
|
||||
}
|
||||
else if(GetArgumentHeap(args,0,dynDict))
|
||||
{
|
||||
return dynDict->GetField(ls,key);
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
TObject Dictionary_SetField(GCList& ls, std::vector<TObject> args)
|
||||
{
|
||||
TDictionary* dict;
|
||||
TDynamicDictionary* dynDict;
|
||||
std::string key;
|
||||
if(args.size() == 3 && GetArgument(args,1,key))
|
||||
{
|
||||
if(GetArgumentHeap(args,0,dict))
|
||||
{
|
||||
ls.GetGC()->BarrierBegin();
|
||||
dict->SetValue(key,args[2]);
|
||||
ls.GetGC()->BarrierEnd();
|
||||
}
|
||||
else if(GetArgumentHeap(args,0,dynDict))
|
||||
{
|
||||
dynDict->SetField(ls,key,args[2]);
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
TObject Dictionary_GetField(GCList& ls, std::vector<TObject> args)
|
||||
{
|
||||
TDictionary* dict;
|
||||
TDynamicDictionary* dynDict;
|
||||
std::string key;
|
||||
if(GetArgument(args,1,key))
|
||||
{
|
||||
if(GetArgumentHeap(args,0,dict))
|
||||
{
|
||||
ls.GetGC()->BarrierBegin();
|
||||
auto res = dict->GetValue(key);
|
||||
ls.GetGC()->BarrierEnd();
|
||||
return res;
|
||||
}
|
||||
else if(GetArgumentHeap(args,0,dynDict))
|
||||
{
|
||||
return dynDict->GetField(ls,key);
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
void TStd::RegisterDictionary(GC* gc,TRootEnvironment* env)
|
||||
{
|
||||
|
||||
@ -43,6 +119,8 @@ namespace Tesses::CrossLang
|
||||
gc->BarrierBegin();
|
||||
|
||||
dict->DeclareFunction(gc, "Items","Get Dictionary Item Enumerable, for the each(item : Dictionary.Items(myDict)){item.Key; item.Value;}",{"dictionary"},Dictionary_Items);
|
||||
dict->DeclareFunction(gc, "SetField","Set a field in dictionary",{"dict","key","value"},Dictionary_SetField);
|
||||
dict->DeclareFunction(gc, "GetField","Get a field in dictionary",{"dict","key"},Dictionary_GetField);
|
||||
|
||||
env->DeclareVariable("Dictionary", dict);
|
||||
gc->BarrierEnd();
|
||||
|
||||
Reference in New Issue
Block a user