diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..4295729 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +build +bin \ No newline at end of file diff --git a/.gitignore b/.gitignore index 96dbce0..76e7f96 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ build +builds bin *.db *.crvm diff --git a/CMakeLists.txt b/CMakeLists.txt index a81a070..797eaf4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,10 +14,9 @@ option(CROSSLANG_ENABLE_PROCESS "Enable process" ON) option(CROSSLANG_ENABLE_SDL2 "Enable SDL2 (For Drawing)" ON) option(CROSSLANG_ENABLE_TERMIOS "Enable termios (For changing terminal options)" ON) -option(CROSSLANG_ENABLE_64BIT_FILE "Allow files over 2GiB" ON) -set(JANSSON_DIR "Directory for Jansson" "") +set(JANSSON_DIR "Directory for Jansson" CACHE PATH "Jansson directory") find_package(TessesFramework REQUIRED) diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8b2cf28 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM ubuntu:noble +RUN apt update -y && \ + apt install -y --no-install-recommends \ + libjansson-dev cmake git ca-certificates wget libmbedtls-dev g++ gcc libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev build-essential && \ + apt clean -y && \ + rm -rf /var/lib/apt/lists/* +WORKDIR /tmp +RUN git clone https://gitea.site.tesses.net/tesses50/tesses-framework && cd tesses-framework && mkdir build && cd build && cmake -S .. -B . && make -j4 && make install && cd /tmp && rm -r /tmp/tesses-framework +COPY . /src +WORKDIR /src +RUN mkdir build && cd build && cmake -S .. -B . && make -j4 && make install && cd / && rm -r /src +WORKDIR / diff --git a/README.md b/README.md index da1b70a..dff15a7 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,13 @@ Tesses Cross Language - CMake - SDL2 (but can be turned off) +## Use in docker +```bash + git clone https://gitea.site.tesses.net/tesses50/crosslang + cd crosslang + sudo docker build -t crosslang:latest . +``` + ## To Install - [Follow TessesFramework setup](https://gitea.site.tesses.net/tesses50/tesses-framework) - Follow the commands bellow diff --git a/src/compiler/parser.cpp b/src/compiler/parser.cpp index df551a7..3b33264 100644 --- a/src/compiler/parser.cpp +++ b/src/compiler/parser.cpp @@ -670,7 +670,7 @@ namespace Tesses::CrossLang { expr = AdvancedSyntaxNode::Create(LessThanEqualsExpression, true, {expr,ParseShift()}); } - else if(tkn.text == ">") + else if(tkn.text == ">=") { expr = AdvancedSyntaxNode::Create(GreaterThanEqualsExpression, true, {expr,ParseShift()}); } diff --git a/src/runtime_methods/env.cpp b/src/runtime_methods/env.cpp index a6b6d71..d145530 100644 --- a/src/runtime_methods/env.cpp +++ b/src/runtime_methods/env.cpp @@ -1,9 +1,22 @@ #include "CrossLang.hpp" #include "../sago/platform_folders.h" +#if defined(_WIN32) +#include +#endif namespace Tesses::CrossLang { + static std::string GetHomeFolder() + { + #if !defined(SAGO_DISABLE) + return sago::getHomeDir(); + #elif defined(__EMSCRIPTEN__) + return "/home/web_user"; + #else + return "/CrossLangProfile"; + #endif + } static TObject Env_getPlatform(GCList& ls, std::vector args) { #if defined(__SWITCH__) @@ -52,7 +65,7 @@ namespace Tesses::CrossLang std::string key; if(GetArgument(args,0,key)) { - auto res = getenv(key.c_str()); + auto res = std::getenv(key.c_str()); if(res == nullptr) return nullptr; std::string value = res; return value; @@ -66,57 +79,108 @@ namespace Tesses::CrossLang if(GetArgument(args,0,key)) { if(GetArgument(args,1,value)) - setenv(key.c_str(), value.c_str(),1); + #if defined(_WIN32) + SetEnvironmentVariable(key.c_str(),value.c_str()); + #else + setenv(key.c_str(), value.c_str(),1); + #endif else + #if defined(_WIN32) + { + + } + #else unsetenv(key.c_str()); + #endif return value; } return nullptr; } static TObject Env_getDownloads(GCList& ls, std::vector args) { + #if !defined(SAGO_DISABLE) return sago::getDownloadFolder(); + #else + return GetHomeFolder() + "/Downloads"; + #endif } static TObject Env_getMusic(GCList& ls, std::vector args) { + + #if !defined(SAGO_DISABLE) return sago::getMusicFolder(); + #else + return GetHomeFolder() + "/Music"; + #endif } static TObject Env_getPictures(GCList& ls, std::vector args) { - return sago::getMusicFolder(); + #if !defined(SAGO_DISABLE) + return sago::getPicturesFolder(); + #else + return GetHomeFolder() + "/Pictures"; + #endif } static TObject Env_getVideos(GCList& ls, std::vector args) { + #if !defined(SAGO_DISABLE) return sago::getVideoFolder(); + #else + return GetHomeFolder() + "/Videos"; + #endif } static TObject Env_getDocuments(GCList& ls, std::vector args) { + #if !defined(SAGO_DISABLE) return sago::getDocumentsFolder(); + #else + return GetHomeFolder() + "/Documents"; + #endif } static TObject Env_getConfig(GCList& ls, std::vector args) { + #if !defined(SAGO_DISABLE) return sago::getConfigHome(); + #else + return GetHomeFolder() + "/Config"; + #endif } static TObject Env_getDesktop(GCList& ls, std::vector args) { + #if !defined(SAGO_DISABLE) return sago::getDesktopFolder(); + #else + return GetHomeFolder() + "/Desktop"; + #endif } static TObject Env_getState(GCList& ls, std::vector args) { + #if !defined(SAGO_DISABLE) return sago::getStateDir(); + #else + return GetHomeFolder() + "/State"; + #endif } static TObject Env_getCache(GCList& ls, std::vector args) { + #if !defined(SAGO_DISABLE) return sago::getCacheDir(); + #else + return GetHomeFolder() + "/Cache"; + #endif } static TObject Env_getData(GCList& ls, std::vector args) { + #if !defined(SAGA_DISABLE) return sago::getDataHome(); + #else + return GetHomeFolder() + "/Data"; + #endif } static TObject Env_getUser(GCList& ls, std::vector args) { - return sago::getHomeDir(); + return GetHomeFolder(); } void TStd::RegisterEnv(GC* gc, TRootEnvironment* env) { diff --git a/src/runtime_methods/net.cpp b/src/runtime_methods/net.cpp index c3b16e3..398441a 100644 --- a/src/runtime_methods/net.cpp +++ b/src/runtime_methods/net.cpp @@ -1,12 +1,7 @@ #include "CrossLang.hpp" #include -#include -#include -#include #include -#include #include -#include #include #include using namespace Tesses::Framework::Streams; @@ -552,4 +547,4 @@ namespace Tesses::CrossLang env->DeclareVariable("Net", dict); gc->BarrierEnd(); } -} \ No newline at end of file +} diff --git a/src/sago/platform_folders.cpp b/src/sago/platform_folders.cpp index 88d0990..ed4ffd7 100644 --- a/src/sago/platform_folders.cpp +++ b/src/sago/platform_folders.cpp @@ -26,6 +26,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/* +Modified by Mike Nolan for this project +I modified it to return home directory and conditionally compile for systems that are not GEKKO / NX etc +*/ + +#if !defined(SAGO_DISABLE) #include "platform_folders.h" #include #include @@ -218,7 +224,12 @@ std::string getDataHome() { } std::string getHomeDir() { + #if defined(_WIN32) + + return GetKnownWindowsFolder(FOLDERID_Profile, "Profile could not be found"); + #else return getHome(); + #endif } std::string getConfigHome() { #ifdef _WIN32 @@ -458,3 +469,4 @@ std::string getSaveGamesFolder2() { } } //namespace sago +#endif diff --git a/src/sago/platform_folders.h b/src/sago/platform_folders.h index bc4ac87..a3e574f 100644 --- a/src/sago/platform_folders.h +++ b/src/sago/platform_folders.h @@ -26,9 +26,25 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/* +Modified by Mike Nolan for this project +I modified it to return home directory and conditionally compile for systems that are not GEKKO / NX etc +*/ + + + + #ifndef SAGO_PLATFORM_FOLDERS_H #define SAGO_PLATFORM_FOLDERS_H +#if defined(GEKKO) || defined(__SWITCH__) || defined(__EMSCRIPTEN__) +#define SAGO_DISABLE +#endif + + + +#if !defined(SAGO_DISABLE) + #include #include @@ -285,5 +301,5 @@ private: } //namespace sago - +#endif #endif /* PLATFORM_FOLDERS_H */ diff --git a/src/vm/vm.cpp b/src/vm/vm.cpp index d62d521..f76962b 100644 --- a/src/vm/vm.cpp +++ b/src/vm/vm.cpp @@ -919,7 +919,7 @@ namespace Tesses::CrossLang { if(std::holds_alternative(left) && std::holds_alternative(right)) { - cse.back()->Push(gc,std::get(left) || std::get(right)); + cse.back()->Push(gc,std::get(left) | std::get(right)); } else if(std::holds_alternative(left)) { @@ -928,7 +928,7 @@ namespace Tesses::CrossLang { if(dict != nullptr) { gc->BarrierBegin(); - TObject fn = dict->GetValue("operator||"); + TObject fn = dict->GetValue("operator|"); gc->BarrierEnd(); return InvokeTwo(ls,fn,left,right); } @@ -989,7 +989,7 @@ namespace Tesses::CrossLang { if(std::holds_alternative(left) && std::holds_alternative(right)) { - cse.back()->Push(gc,std::get(left) && std::get(right)); + cse.back()->Push(gc,std::get(left) & std::get(right)); } else if(std::holds_alternative(left)) { @@ -998,7 +998,7 @@ namespace Tesses::CrossLang { if(dict != nullptr) { gc->BarrierBegin(); - TObject fn = dict->GetValue("operator&&"); + TObject fn = dict->GetValue("operator&"); gc->BarrierEnd(); return InvokeTwo(ls,fn,left,right); } @@ -3597,6 +3597,7 @@ namespace Tesses::CrossLang { break; case RIGHTSHIFT: TVM_HANDLER(RShift); + break; case LESSTHAN: TVM_HANDLER(Lt); break; @@ -4179,19 +4180,9 @@ namespace Tesses::CrossLang { auto dict = dynamic_cast(obj); if(dict != nullptr) { - gc->BarrierBegin(); - auto v = dict->GetValue("ToString"); - gc->BarrierEnd(); - if(std::holds_alternative(v)) - { - auto callable=dynamic_cast(std::get(v).obj); - if(callable != nullptr) - { - GCList ls(gc); - auto res = callable->Call(ls,{}); - return ToString(gc,res); - } - } + GCList ls(gc); + return ToString(gc,dict->CallMethod(ls,"ToString",{})); + } }