Add markedtobject
This commit is contained in:
@ -118,6 +118,7 @@ src/vm/gclist.cpp
|
|||||||
src/vm/vm.cpp
|
src/vm/vm.cpp
|
||||||
src/bitconverter.cpp
|
src/bitconverter.cpp
|
||||||
src/archive.cpp
|
src/archive.cpp
|
||||||
|
src/markedtobject.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
if(CROSSLANG_ENABLE_PLATFORM_FOLDERS)
|
if(CROSSLANG_ENABLE_PLATFORM_FOLDERS)
|
||||||
|
|||||||
@ -1571,4 +1571,20 @@ class GC {
|
|||||||
void LoadPlugin(GC* gc, TRootEnvironment* env, Tesses::Framework::Filesystem::VFSPath sharedObjectPath);
|
void LoadPlugin(GC* gc, TRootEnvironment* env, Tesses::Framework::Filesystem::VFSPath sharedObjectPath);
|
||||||
std::string Json_Encode(TObject o,bool indent=false);
|
std::string Json_Encode(TObject o,bool indent=false);
|
||||||
TObject Json_Decode(GCList ls,std::string str);
|
TObject Json_Decode(GCList ls,std::string str);
|
||||||
|
//DO NOT USE DIRECTLY
|
||||||
|
class SharedPtrTObject {
|
||||||
|
GCList* ls;
|
||||||
|
TObject o;
|
||||||
|
public:
|
||||||
|
SharedPtrTObject(GC* gc, TObject o);
|
||||||
|
TObject& GetObject();
|
||||||
|
GC* GetGC();
|
||||||
|
~SharedPtrTObject();
|
||||||
|
};
|
||||||
|
using MarkedTObject = std::shared_ptr<SharedPtrTObject>;
|
||||||
|
|
||||||
|
MarkedTObject CreateMarkedTObject(GC* gc, TObject o);
|
||||||
|
MarkedTObject CreateMarkedTObject(GC& gc, TObject o);
|
||||||
|
MarkedTObject CreateMarkedTObject(GCList* gc, TObject o);
|
||||||
|
MarkedTObject CreateMarkedTObject(GCList& gc, TObject o);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -53,8 +53,7 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
Tesses::Framework::Filesystem::VFSPath dir = sago::getConfigHome();
|
Tesses::Framework::Filesystem::VFSPath dir = GetCrossLangConfigDir();
|
||||||
dir = dir / "Tesses" / "CrossLang";
|
|
||||||
|
|
||||||
Tesses::Framework::Filesystem::VFSPath filename = dir / "Shell" / "Shell.crvm";
|
Tesses::Framework::Filesystem::VFSPath filename = dir / "Shell" / "Shell.crvm";
|
||||||
|
|
||||||
|
|||||||
40
src/markedtobject.cpp
Normal file
40
src/markedtobject.cpp
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
#include <CrossLang.hpp>
|
||||||
|
|
||||||
|
namespace Tesses::CrossLang
|
||||||
|
{
|
||||||
|
SharedPtrTObject::SharedPtrTObject(GC* gc, TObject o)
|
||||||
|
{
|
||||||
|
this->ls = new GCList(gc);
|
||||||
|
this->ls->Add(o);
|
||||||
|
this->o = o;
|
||||||
|
}
|
||||||
|
TObject& SharedPtrTObject::GetObject()
|
||||||
|
{
|
||||||
|
return this->o;
|
||||||
|
}
|
||||||
|
SharedPtrTObject::~SharedPtrTObject()
|
||||||
|
{
|
||||||
|
if(this->ls)
|
||||||
|
delete this->ls;
|
||||||
|
}
|
||||||
|
GC* SharedPtrTObject::GetGC()
|
||||||
|
{
|
||||||
|
return this->ls->GetGC();
|
||||||
|
}
|
||||||
|
MarkedTObject CreateMarkedTObject(GC* gc, TObject o)
|
||||||
|
{
|
||||||
|
return std::make_shared<SharedPtrTObject>(gc,o);
|
||||||
|
}
|
||||||
|
MarkedTObject CreateMarkedTObject(GC& gc, TObject o)
|
||||||
|
{
|
||||||
|
return CreateMarkedTObject(&gc,o);
|
||||||
|
}
|
||||||
|
MarkedTObject CreateMarkedTObject(GCList* gc, TObject o)
|
||||||
|
{
|
||||||
|
return CreateMarkedTObject(gc->GetGC(),o);
|
||||||
|
}
|
||||||
|
MarkedTObject CreateMarkedTObject(GCList& gc, TObject o)
|
||||||
|
{
|
||||||
|
return CreateMarkedTObject(gc.GetGC(),o);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -2,7 +2,7 @@
|
|||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#if defined(GEKKO)
|
#if defined(GEKKO) || defined(__SWITCH__)
|
||||||
#undef CROSSLANG_ENABLE_TERMIOS
|
#undef CROSSLANG_ENABLE_TERMIOS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
|
|
||||||
#include <TessesFramework/TessesFrameworkFeatures.h>
|
#include <TessesFramework/TessesFrameworkFeatures.h>
|
||||||
#if defined(TESSESFRAMEWORK_ENABLE_MBED)
|
#if defined(TESSESFRAMEWORK_ENABLE_MBED)
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|||||||
@ -13,7 +13,16 @@ namespace Tesses::CrossLang
|
|||||||
#else
|
#else
|
||||||
static char EnvPathSeperator=':';
|
static char EnvPathSeperator=':';
|
||||||
#endif
|
#endif
|
||||||
|
static std::string GetHomeFolder()
|
||||||
|
{
|
||||||
|
#if defined(CROSSLANG_ENABLE_PLATFORM_FOLDERS)
|
||||||
|
return sago::getHomeDir();
|
||||||
|
#elif defined(__EMSCRIPTEN__)
|
||||||
|
return "/home/web_user";
|
||||||
|
#else
|
||||||
|
return "/CrossLangProfile";
|
||||||
|
#endif
|
||||||
|
}
|
||||||
Tesses::Framework::Filesystem::VFSPath GetCrossLangConfigDir()
|
Tesses::Framework::Filesystem::VFSPath GetCrossLangConfigDir()
|
||||||
{
|
{
|
||||||
Tesses::Framework::Filesystem::VFSPath p;
|
Tesses::Framework::Filesystem::VFSPath p;
|
||||||
@ -58,16 +67,7 @@ namespace Tesses::CrossLang
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string GetHomeFolder()
|
|
||||||
{
|
|
||||||
#if defined(CROSSLANG_ENABLE_PLATFORM_FOLDERS)
|
|
||||||
return sago::getHomeDir();
|
|
||||||
#elif defined(__EMSCRIPTEN__)
|
|
||||||
return "/home/web_user";
|
|
||||||
#else
|
|
||||||
return "/CrossLangProfile";
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
static TObject Env_getCrossLangConfig(GCList& ls, std::vector<TObject> args)
|
static TObject Env_getCrossLangConfig(GCList& ls, std::vector<TObject> args)
|
||||||
{
|
{
|
||||||
return GetCrossLangConfigDir();
|
return GetCrossLangConfigDir();
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
|
|
||||||
#if defined(GEKKO)
|
#if defined(GEKKO) || defined(__SWITCH__)
|
||||||
#undef CROSSLANG_ENABLE_PROCESS
|
#undef CROSSLANG_ENABLE_PROCESS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@ -8,8 +8,13 @@ namespace Tesses::CrossLang
|
|||||||
{
|
{
|
||||||
static int64_t ToLocalTime(int64_t local)
|
static int64_t ToLocalTime(int64_t local)
|
||||||
{
|
{
|
||||||
|
#if defined(__SWITCH__)
|
||||||
|
local -= _timezone;
|
||||||
|
if(_daylight)
|
||||||
|
#else
|
||||||
local -= timezone;
|
local -= timezone;
|
||||||
if(daylight)
|
if(daylight)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
auto epoch = date::sys_days{date::January/1/1970};
|
auto epoch = date::sys_days{date::January/1/1970};
|
||||||
epoch += date::days(local/86400);
|
epoch += date::days(local/86400);
|
||||||
@ -163,8 +168,13 @@ namespace Tesses::CrossLang
|
|||||||
dict->DeclareFunction(gc, "Sleep","Sleep for a specified amount of milliseconds (multiply seconds by 1000 to get milliseconds)", {"ms"},Time_Sleep);
|
dict->DeclareFunction(gc, "Sleep","Sleep for a specified amount of milliseconds (multiply seconds by 1000 to get milliseconds)", {"ms"},Time_Sleep);
|
||||||
|
|
||||||
gc->BarrierBegin();
|
gc->BarrierBegin();
|
||||||
|
#if defined(__SWITCH__)
|
||||||
|
dict->SetValue("Zone", (int64_t)-(_timezone));
|
||||||
|
dict->SetValue("SupportsDaylightSavings",(int64_t)_daylight);
|
||||||
|
#else
|
||||||
dict->SetValue("Zone", (int64_t)-(timezone));
|
dict->SetValue("Zone", (int64_t)-(timezone));
|
||||||
dict->SetValue("SupportsDaylightSavings",(int64_t)daylight);
|
dict->SetValue("SupportsDaylightSavings",(int64_t)daylight);
|
||||||
|
#endif
|
||||||
env->DeclareVariable("Time", dict);
|
env->DeclareVariable("Time", dict);
|
||||||
|
|
||||||
gc->BarrierEnd();
|
gc->BarrierEnd();
|
||||||
|
|||||||
@ -21,7 +21,7 @@
|
|||||||
** c9c2ab54ba1f5f46360f1b4f35d849cd3f08.
|
** c9c2ab54ba1f5f46360f1b4f35d849cd3f08.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(GEKKO)
|
#if defined(GEKKO) || defined(__SWITCH__)
|
||||||
//-DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_OMIT_WAL -DSQLITE_THREADSAFE=0
|
//-DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_OMIT_WAL -DSQLITE_THREADSAFE=0
|
||||||
#define SQLITE_OMIT_LOAD_EXTENSION
|
#define SQLITE_OMIT_LOAD_EXTENSION
|
||||||
#define SQLITE_OMIT_WAL
|
#define SQLITE_OMIT_WAL
|
||||||
|
|||||||
@ -115,7 +115,7 @@
|
|||||||
|
|
||||||
/*removed tests from https://www.sqlite.org/src/doc/trunk/src/test_demovfs.c*/
|
/*removed tests from https://www.sqlite.org/src/doc/trunk/src/test_demovfs.c*/
|
||||||
|
|
||||||
#if defined(GEKKO)
|
#if defined(GEKKO) || defined(__SWITCH__)
|
||||||
|
|
||||||
#include "sqlite3.h"
|
#include "sqlite3.h"
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#include "../sqlite/sqlite3.h"
|
#include "../sqlite/sqlite3.h"
|
||||||
}
|
}
|
||||||
#if defined(GEKKO)
|
#if defined(GEKKO) || defined(__SWITCH__)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
sqlite3_vfs *sqlite3_demovfs();
|
sqlite3_vfs *sqlite3_demovfs();
|
||||||
}
|
}
|
||||||
@ -31,7 +31,7 @@ namespace Tesses::CrossLang
|
|||||||
tzset();
|
tzset();
|
||||||
#if defined(CROSSLANG_ENABLE_SQLITE)
|
#if defined(CROSSLANG_ENABLE_SQLITE)
|
||||||
sqlite3_initialize();
|
sqlite3_initialize();
|
||||||
#if defined(GEKKO)
|
#if defined(GEKKO) || defined(__SWITCH__)
|
||||||
sqlite3_vfs_register(sqlite3_demovfs(),1);
|
sqlite3_vfs_register(sqlite3_demovfs(),1);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user