Add GUI Support
This commit is contained in:
5
.vscode/c_cpp_properties.json
vendored
5
.vscode/c_cpp_properties.json
vendored
@ -16,11 +16,10 @@
|
|||||||
"CROSSLANG_ENABLE_TERMIOS=1",
|
"CROSSLANG_ENABLE_TERMIOS=1",
|
||||||
"CROSSLANG_ENABLE_MBED=1",
|
"CROSSLANG_ENABLE_MBED=1",
|
||||||
"CROSSLANG_ENABLE_SQLITE=1",
|
"CROSSLANG_ENABLE_SQLITE=1",
|
||||||
"CROSSLANG_ENABLE_SDL2=1",
|
"TESSESFRAMEWORK_ENABLE_SDL2=1",
|
||||||
"CROSSLANG_ENABLE_PROCESS=1",
|
"CROSSLANG_ENABLE_PROCESS=1",
|
||||||
"CROSSLANG_ENABLE_FFI=1",
|
"CROSSLANG_ENABLE_FFI=1",
|
||||||
"CROSSLANG_ENABLE_SHARED=1",
|
"CROSSLANG_ENABLE_SHARED=1"
|
||||||
"CROSSLANG_ENABLE_GOBJECT_FFI=1"
|
|
||||||
],
|
],
|
||||||
"compilerPath": "/usr/bin/gcc",
|
"compilerPath": "/usr/bin/gcc",
|
||||||
"cStandard": "c17",
|
"cStandard": "c17",
|
||||||
|
|||||||
@ -143,6 +143,7 @@ src/runtime_methods/ogc.cpp
|
|||||||
src/runtime_methods/path.cpp
|
src/runtime_methods/path.cpp
|
||||||
src/runtime_methods/env.cpp
|
src/runtime_methods/env.cpp
|
||||||
src/runtime_methods/process.cpp
|
src/runtime_methods/process.cpp
|
||||||
|
src/runtime_methods/sdl2.cpp
|
||||||
src/types/associativearray.cpp
|
src/types/associativearray.cpp
|
||||||
src/types/any.cpp
|
src/types/any.cpp
|
||||||
src/types/datetime.cpp
|
src/types/datetime.cpp
|
||||||
|
|||||||
@ -1762,6 +1762,7 @@ class GC {
|
|||||||
bool canRegisterOGC;
|
bool canRegisterOGC;
|
||||||
bool canRegisterEnv;
|
bool canRegisterEnv;
|
||||||
bool canRegisterClass;
|
bool canRegisterClass;
|
||||||
|
bool canRegisterSDL2;
|
||||||
bool sqlite3Scoped;
|
bool sqlite3Scoped;
|
||||||
bool locked;
|
bool locked;
|
||||||
};
|
};
|
||||||
@ -1821,6 +1822,7 @@ class GC {
|
|||||||
static void RegisterEnv(GC* gc, TRootEnvironment* env);
|
static void RegisterEnv(GC* gc, TRootEnvironment* env);
|
||||||
static void RegisterProcess(GC* gc, TRootEnvironment* env);
|
static void RegisterProcess(GC* gc, TRootEnvironment* env);
|
||||||
static void RegisterClass(GC* gc, TRootEnvironment* env);
|
static void RegisterClass(GC* gc, TRootEnvironment* env);
|
||||||
|
static void RegisterSDL2(GC* gc,TRootEnvironment* env);
|
||||||
};
|
};
|
||||||
|
|
||||||
class TSubEnvironment : public TEnvironment
|
class TSubEnvironment : public TEnvironment
|
||||||
|
|||||||
@ -933,6 +933,7 @@ namespace Tesses::CrossLang
|
|||||||
env->DeclareFunction(gc, "TypeIsDateTime","Get whether object is a DateTime",{"object"},TypeIsDateTime);
|
env->DeclareFunction(gc, "TypeIsDateTime","Get whether object is a DateTime",{"object"},TypeIsDateTime);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
newTypes->DeclareFunction(gc, "Regex", "Create regex object",{"regex"},[](GCList& ls,std::vector<TObject> args)->TObject {
|
newTypes->DeclareFunction(gc, "Regex", "Create regex object",{"regex"},[](GCList& ls,std::vector<TObject> args)->TObject {
|
||||||
std::string str;
|
std::string str;
|
||||||
if(GetArgument(args,0,str))
|
if(GetArgument(args,0,str))
|
||||||
@ -1075,6 +1076,7 @@ namespace Tesses::CrossLang
|
|||||||
RegisterOGC(gc, env);
|
RegisterOGC(gc, env);
|
||||||
RegisterProcess(gc,env);
|
RegisterProcess(gc,env);
|
||||||
RegisterClass(gc,env);
|
RegisterClass(gc,env);
|
||||||
|
RegisterSDL2(gc,env);
|
||||||
|
|
||||||
gc->RegisterEverything(env);
|
gc->RegisterEverything(env);
|
||||||
|
|
||||||
|
|||||||
@ -5,6 +5,101 @@
|
|||||||
|
|
||||||
namespace Tesses::CrossLang
|
namespace Tesses::CrossLang
|
||||||
{
|
{
|
||||||
|
|
||||||
|
class OnItterationObj : public TNativeObject
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
GC* gc;
|
||||||
|
std::vector<TCallable*> callables;
|
||||||
|
std::shared_ptr<Tesses::Framework::FunctionalEvent<uint64_t>> fevent;
|
||||||
|
public:
|
||||||
|
OnItterationObj(GC* gc)
|
||||||
|
{
|
||||||
|
this->gc=gc;
|
||||||
|
this->fevent = std::make_shared<Tesses::Framework::FunctionalEvent<uint64_t>>(
|
||||||
|
[this](uint64_t n)->void{
|
||||||
|
this->Exec(n);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
Tesses::Framework::OnItteraton += this->fevent;
|
||||||
|
}
|
||||||
|
~OnItterationObj()
|
||||||
|
{
|
||||||
|
Tesses::Framework::OnItteraton -= this->fevent;
|
||||||
|
}
|
||||||
|
std::string TypeName()
|
||||||
|
{
|
||||||
|
return "OnItteration";
|
||||||
|
}
|
||||||
|
TObject CallMethod(GCList& ls, std::string key, std::vector<TObject> args)
|
||||||
|
{
|
||||||
|
if(key == "operator+")
|
||||||
|
{
|
||||||
|
TCallable* callable;
|
||||||
|
if(GetArgumentHeap(args,0,callable))
|
||||||
|
{
|
||||||
|
gc->BarrierBegin();
|
||||||
|
bool found=false;
|
||||||
|
for(auto item : this->callables)
|
||||||
|
{
|
||||||
|
if(item == callable) {found=true; break;}
|
||||||
|
}
|
||||||
|
if(!found)
|
||||||
|
{
|
||||||
|
this->callables.push_back(callable);
|
||||||
|
}
|
||||||
|
gc->BarrierEnd();
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
if(key == "operator-")
|
||||||
|
{
|
||||||
|
TCallable* callable;
|
||||||
|
if(GetArgumentHeap(args,0,callable))
|
||||||
|
{
|
||||||
|
gc->BarrierBegin();
|
||||||
|
|
||||||
|
for(auto index = this->callables.begin(); index < this->callables.end(); index++)
|
||||||
|
{
|
||||||
|
if(*index == callable) {
|
||||||
|
this->callables.erase(index);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gc->BarrierEnd();
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
if(key == "ToString")
|
||||||
|
{
|
||||||
|
gc->BarrierBegin();
|
||||||
|
std::string str = "Registered: " + std::to_string(this->callables.size());
|
||||||
|
gc->BarrierEnd();
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
return Undefined();
|
||||||
|
}
|
||||||
|
void Mark()
|
||||||
|
{
|
||||||
|
if(this->marked) return;
|
||||||
|
this->marked=true;
|
||||||
|
|
||||||
|
for(auto item : callables) item->Mark();
|
||||||
|
}
|
||||||
|
void Exec(uint64_t n)
|
||||||
|
{
|
||||||
|
gc->BarrierBegin();
|
||||||
|
for(auto item : callables)
|
||||||
|
{
|
||||||
|
gc->BarrierEnd();
|
||||||
|
GCList ls(gc);
|
||||||
|
item->Call(ls,{(int64_t)n});
|
||||||
|
gc->BarrierBegin();
|
||||||
|
}
|
||||||
|
gc->BarrierEnd();
|
||||||
|
}
|
||||||
|
};
|
||||||
static TObject AstToTObject(GCList& ls,SyntaxNode node)
|
static TObject AstToTObject(GCList& ls,SyntaxNode node)
|
||||||
{
|
{
|
||||||
if(std::holds_alternative<std::nullptr_t>(node))
|
if(std::holds_alternative<std::nullptr_t>(node))
|
||||||
@ -317,8 +412,24 @@ namespace Tesses::CrossLang
|
|||||||
dict->DeclareFunction(gc, "getRuntimeVersion","Get the runtime version",{},[](GCList& ls,std::vector<TObject> args)->TObject {
|
dict->DeclareFunction(gc, "getRuntimeVersion","Get the runtime version",{},[](GCList& ls,std::vector<TObject> args)->TObject {
|
||||||
return TVMVersion(TVM_MAJOR,TVM_MINOR,TVM_PATCH,TVM_BUILD,TVM_VERSIONSTAGE);
|
return TVMVersion(TVM_MAJOR,TVM_MINOR,TVM_PATCH,TVM_BUILD,TVM_VERSIONSTAGE);
|
||||||
});
|
});
|
||||||
|
dict->DeclareFunction(gc, "getIsRunning","Is the program still running",{},[](GCList& ls, std::vector<TObject> args)->TObject {
|
||||||
|
return Tesses::Framework::TF_IsRunning();
|
||||||
|
});
|
||||||
|
dict->DeclareFunction(gc, "RunEventLoopItteration","Run Event Loop Itteration",{},[](GCList& ls, std::vector<TObject> args)->TObject {
|
||||||
|
Tesses::Framework::TF_RunEventLoopItteration();
|
||||||
|
return Undefined();
|
||||||
|
});
|
||||||
|
dict->DeclareFunction(gc, "RunEventLoop","Run Event Loop",{},[](GCList& ls, std::vector<TObject> args)->TObject {
|
||||||
|
Tesses::Framework::TF_RunEventLoop();
|
||||||
|
return Undefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
gc->BarrierBegin();
|
gc->BarrierBegin();
|
||||||
|
auto ittrobj = TNativeObject::Create<OnItterationObj>(ls,gc);
|
||||||
|
|
||||||
|
|
||||||
|
dict->SetValue("OnItteration", ittrobj);
|
||||||
env->DeclareVariable("VM", dict);
|
env->DeclareVariable("VM", dict);
|
||||||
gc->BarrierEnd();
|
gc->BarrierEnd();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user