fix on macos

This commit is contained in:
2025-05-31 16:23:57 -05:00
parent fe5cb54361
commit 03f28a33db
4 changed files with 114 additions and 3 deletions

View File

@ -16,7 +16,6 @@
#include <TessesFramework/TessesFramework.hpp> #include <TessesFramework/TessesFramework.hpp>
#include <regex> #include <regex>
#include <time.h> #include <time.h>
#include <cstdbool>
#include <any> #include <any>
/** /**

View File

@ -59,6 +59,80 @@ namespace Tesses::CrossLang
TDItem("Entries",EntriesToList(ls,f->classes.at(index).entry)) TDItem("Entries",EntriesToList(ls,f->classes.at(index).entry))
}); });
} }
static TObject Class_CreateInstance(TRootEnvironment* env,GCList& ls, std::vector<TObject> args)
{
TList* args_ls;
if(!GetArgumentHeap(args,1,args_ls)) return nullptr;
TList* list;
TClassObject* obj;
std::string str;
if(GetArgumentHeap(args,0,list))
{
std::vector<std::string> clsName;
for(int64_t i = 0; i < list->Count(); i++)
{
auto o = list->Get(i);
if(GetObject(o,str)) clsName.push_back(str);
}
for(auto& item : env->classes)
{
auto& f=item.first->classes.at(item.second);
if(f.name.size() != clsName.size()) continue;
bool found=true;
for(size_t i = 0; i < f.name.size(); i++)
if(f.name[i] != clsName[i])
{
found=false;
break;
}
if(found)
{
return TClassObject::Create(ls,item.first,item.second,env,args_ls->items);
}
else
continue;
}
}
else if(GetArgument(args,0,str))
{
std::vector<std::string> clsName=Tesses::Framework::Http::HttpUtils::SplitString(str,".");
for(auto& item : env->classes)
{
auto& f=item.first->classes.at(item.second);
if(f.name.size() != clsName.size()) continue;
bool found=true;
for(size_t i = 0; i < f.name.size(); i++)
if(f.name[i] != clsName[i])
{
found=false;
break;
}
if(found)
{
return TClassObject::Create(ls,item.first,item.second,env,args_ls->items);
}
else
continue;
}
}
return nullptr;
}
static TObject Class_GetClassNames(TRootEnvironment* env,GCList& ls, std::vector<TObject> args)
{
TList* list = TList::Create(ls);
ls.GetGC()->BarrierBegin();
for(auto& item : env->classes)
{
list->Add(JoinPeriod(item.first->classes.at(item.second).name));
}
ls.GetGC()->BarrierEnd();
return list;
}
static TObject Class_GetInfo(TRootEnvironment* env,GCList& ls, std::vector<TObject> args) static TObject Class_GetInfo(TRootEnvironment* env,GCList& ls, std::vector<TObject> args)
{ {
@ -138,6 +212,28 @@ namespace Tesses::CrossLang
ext->watch.push_back(env); ext->watch.push_back(env);
cls->SetValue("GetInfo",ext); cls->SetValue("GetInfo",ext);
ext = TExternalMethod::Create(ls ,"Get the class names",{},[env](GCList& ls, std::vector<TObject> args)->TObject {
return Class_GetClassNames(env,ls,args);
});
ext->watch.push_back(env);
cls->SetValue("GetClassNames",ext);
ext = TExternalMethod::Create(ls ,"Create an instance of class",{"name","args"},[env](GCList& ls, std::vector<TObject> args)->TObject {
return Class_CreateInstance(env,ls,args);
});
ext->watch.push_back(env);
cls->SetValue("CreateInstance",ext);
cls->DeclareFunction(gc,"Name","Get class name via instance",{"instance"},[](GCList& ls, std::vector<TObject> args)->TObject {
TClassObject* cls;
if(GetArgumentHeap(args,0,cls))
{
return cls->name;
}
return "";
});
gc->BarrierEnd(); gc->BarrierEnd();
} }
} }

View File

@ -81,7 +81,7 @@ namespace Tesses::CrossLang
}); });
dict->DeclareFunction(ls.GetGC(),"getFinished","Get whether thread has finished",{},[th](GCList& _ls, std::vector<TObject> _args)-> TObject{ dict->DeclareFunction(ls.GetGC(),"getFinished","Get whether thread has finished",{},[th](GCList& _ls, std::vector<TObject> _args)-> TObject{
return th->hasReturned; return (bool)(th->hasReturned==true);
}); });
ls.GetGC()->BarrierEnd(); ls.GetGC()->BarrierEnd();

View File

@ -5669,7 +5669,9 @@ namespace Tesses::CrossLang {
cse.back()->Push(gc,callable->Call(ls,{value})); cse.back()->Push(gc,callable->Call(ls,{value}));
return false; return false;
} }
gc->BarrierBegin();
cls->SetValue(cse.back()->callable->className,key,value); cls->SetValue(cse.back()->callable->className,key,value);
gc->BarrierEnd();
cse.back()->Push(gc,value); cse.back()->Push(gc,value);
return false; return false;
@ -6277,12 +6279,26 @@ namespace Tesses::CrossLang {
if(std::holds_alternative<THeapObjectHolder>(objhold) && std::holds_alternative<std::string>(k)) if(std::holds_alternative<THeapObjectHolder>(objhold) && std::holds_alternative<std::string>(k))
{ {
auto dict= dynamic_cast<TDictionary*>(std::get<THeapObjectHolder>(objhold).obj); auto dict= dynamic_cast<TDictionary*>(std::get<THeapObjectHolder>(objhold).obj);
auto cls = dynamic_cast<TClassObject*>(std::get<THeapObjectHolder>(objhold).obj);
if(dict != nullptr) if(dict != nullptr)
{ {
dict->SetValue(std::get<std::string>(k), value); dict->SetValue(std::get<std::string>(k), value);
} }
else if(cls != nullptr)
{
auto obj=cls->GetValue(cse.back()->callable->className,"set"+std::get<std::string>(k));
TCallable* callable;
if(GetObjectHeap(obj,callable))
{
gc->BarrierEnd();
callable->Call(ls,{value});
gc->BarrierBegin();
}else {
cls->SetValue(cse.back()->callable->className,std::get<std::string>(k),value);
}
}
} }
stk->Push(gc, objhold); stk->Push(gc, objhold);