mirror of
https://onedev.site.tesses.net/crosslang
synced 2026-02-08 17:15:45 +00:00
Changing version to 0.0.1
This commit is contained in:
@@ -79,8 +79,6 @@ jobs:
|
|||||||
cd Packaging/Linux
|
cd Packaging/Linux
|
||||||
bash build-ubuntu-plucky.sh
|
bash build-ubuntu-plucky.sh
|
||||||
bash push-ubuntu-plucky.sh
|
bash push-ubuntu-plucky.sh
|
||||||
cd ../CPKG
|
|
||||||
bash winbuild.sh
|
|
||||||
cd ../Windows
|
cd ../Windows
|
||||||
bash build.sh
|
bash build.sh
|
||||||
envVars:
|
envVars:
|
||||||
@@ -102,10 +100,6 @@ jobs:
|
|||||||
bash build-ubuntu-jammy.sh
|
bash build-ubuntu-jammy.sh
|
||||||
bash push-ubuntu-jammy.sh
|
bash push-ubuntu-jammy.sh
|
||||||
bash build-tars.sh
|
bash build-tars.sh
|
||||||
apt update -y
|
|
||||||
apt install -y crosslang
|
|
||||||
cd ../CPKG
|
|
||||||
bash pack_and_publish.sh
|
|
||||||
envVars:
|
envVars:
|
||||||
- name: GITEA_AUTH
|
- name: GITEA_AUTH
|
||||||
value: '@secret:GITEA_AUTH@'
|
value: '@secret:GITEA_AUTH@'
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
cmake_minimum_required(VERSION 3.16)
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
project(TessesCrossLang VERSION 1.0)
|
set(CROSSLANG_MAJOR_VERSION 0)
|
||||||
|
set(CROSSLANG_MINOR_VERSION 0)
|
||||||
|
set(CROSSLANG_PATCH_VERSION 1)
|
||||||
|
|
||||||
|
project(TessesCrossLang VERSION ${CROSSLANG_MAJOR_VERSION}.${CROSSLANG_MINOR_VERSION}.${CROSSLANG_PATCH_VERSION})
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
@@ -78,6 +82,11 @@ if(CROSSLANG_ENABLE_FFI AND CROSSLANG_ENABLE_SHARED)
|
|||||||
pkg_check_modules(LIBFFI REQUIRED IMPORTED_TARGET libffi)
|
pkg_check_modules(LIBFFI REQUIRED IMPORTED_TARGET libffi)
|
||||||
endif()
|
endif()
|
||||||
function(CROSSLANG_LINK_DEPS CROSSLANG_TARGET_NAME)
|
function(CROSSLANG_LINK_DEPS CROSSLANG_TARGET_NAME)
|
||||||
|
target_include_directories(${CROSSLANG_TARGET_NAME}
|
||||||
|
PUBLIC
|
||||||
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>"
|
||||||
|
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
|
||||||
|
)
|
||||||
if(CROSSLANG_ENABLE_FFI AND CROSSLANG_ENABLE_SHARED)
|
if(CROSSLANG_ENABLE_FFI AND CROSSLANG_ENABLE_SHARED)
|
||||||
|
|
||||||
target_compile_definitions(${CROSSLANG_TARGET_NAME} PUBLIC CROSSLANG_ENABLE_FFI)
|
target_compile_definitions(${CROSSLANG_TARGET_NAME} PUBLIC CROSSLANG_ENABLE_FFI)
|
||||||
@@ -245,6 +254,8 @@ install(EXPORT TessesCrossLangTargets
|
|||||||
|
|
||||||
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/TessesCrossLangConfig.cmake"
|
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/TessesCrossLangConfig.cmake"
|
||||||
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/TessesCrossLang)
|
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/TessesCrossLang)
|
||||||
|
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/CrossLangVersion.h.in "${CMAKE_CURRENT_BINARY_DIR}/include/CrossLangVersion.h"
|
||||||
|
INSTALL_DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/CrossLangVersion.h)
|
||||||
|
|
||||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/TessesCrossLangConfig.cmake"
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/TessesCrossLangConfig.cmake"
|
||||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/TessesCrossLang)
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/TessesCrossLang)
|
||||||
|
|||||||
5
CrossLangVersion.h.in
Normal file
5
CrossLangVersion.h.in
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define CROSSLANG_MAJOR @CROSSLANG_MAJOR_VERSION@
|
||||||
|
#define CROSSLANG_MINOR @CROSSLANG_MINOR_VERSION@
|
||||||
|
#define CROSSLANG_PATCH @CROSSLANG_PATCH_VERSION@
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 3.16)
|
|
||||||
|
|
||||||
project(CrossLangPublish)
|
|
||||||
|
|
||||||
option(CROSSAPPPUBLISH_STATIC "Build static version" OFF)
|
|
||||||
|
|
||||||
if(CROSSAPPPUBLISH_STATIC)
|
|
||||||
set(TESSESFRAMEWORK_ENABLE_RPATH OFF CACHE INTERNAL "For TessesFramework" FORCE)
|
|
||||||
set(TESSESFRAMEWORK_ENABLE_STATIC ON CACHE INTERNAL "For TessesFramework" FORCE)
|
|
||||||
set(TESSESFRAMEWORK_ENABLE_EXAMPLES OFF CACHE INTERNAL "For TessesFramework" FORCE)
|
|
||||||
set(TESSESFRAMEWORK_ENABLE_APPS OFF CACHE INTERNAL "For TessesFramework" FORCE)
|
|
||||||
set(TESSESFRAMEWORK_ENABLE_SHARED OFF CACHE INTERNAL "For TessesFramework" FORCE)
|
|
||||||
set(TESSESFRAMEWORK_FETCHCONTENT ON CACHE INTERNAL "For TessesFramework" FORCE)
|
|
||||||
set(CROSSLANG_ENABLE_BINARIES OFF CACHE INTERNAL "For CrossLang" FORCE)
|
|
||||||
else()
|
|
||||||
set(TESSESFRAMEWORK_ENABLE_RPATH OFF CACHE INTERNAL "For TessesFramework" FORCE)
|
|
||||||
set(TESSESFRAMEWORK_ENABLE_STATIC OFF CACHE INTERNAL "For TessesFramework" FORCE)
|
|
||||||
set(TESSESFRAMEWORK_ENABLE_EXAMPLES OFF CACHE INTERNAL "For TessesFramework" FORCE)
|
|
||||||
set(TESSESFRAMEWORK_ENABLE_APPS OFF CACHE INTERNAL "For TessesFramework" FORCE)
|
|
||||||
set(TESSESFRAMEWORK_ENABLE_SHARED ON CACHE INTERNAL "For TessesFramework" FORCE)
|
|
||||||
set(TESSESFRAMEWORK_FETCHCONTENT ON CACHE INTERNAL "For TessesFramework" FORCE)
|
|
||||||
set(CROSSLANG_ENABLE_BINARIES OFF CACHE INTERNAL "For CrossLang" FORCE)
|
|
||||||
set(CMAKE_INSTALL_BINDIR "." CACHE INTERNAL "For CrossLang" FORCE)
|
|
||||||
set(CMAKE_INSTALL_LIBDIR "." CACHE INTERNAL "For CrossLang" FORCE)
|
|
||||||
set(CMAKE_INSTALL_PREFIX "/dir" CACHE INTERNAL "For CrossLang" FORCE)
|
|
||||||
set(CMAKE_PLATFORM_NO_VERSIONED_SONAME ON CACHE INTERNAL "For CrossLang" FORCE)
|
|
||||||
set(CMAKE_MACOSX_RPATH 1)
|
|
||||||
set(CMAKE_BUILD_RPATH_USE_ORIGIN ON CACHE INTERNAL "For CrossLang" FORCE)
|
|
||||||
if (APPLE)
|
|
||||||
set(CMAKE_INSTALL_RPATH "@executable_path/" CACHE INTERNAL "For CrossLang" FORCE)
|
|
||||||
else()
|
|
||||||
set(CMAKE_INSTALL_RPATH "$ORIGIN/" CACHE INTERNAL "For CrossLang" FORCE)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
include(FetchContent)
|
|
||||||
|
|
||||||
FetchContent_Declare(
|
|
||||||
TessesCrossLang
|
|
||||||
GIT_REPOSITORY https://onedev.site.tesses.net/crosslang.git
|
|
||||||
)
|
|
||||||
|
|
||||||
FetchContent_MakeAvailable(TessesCrossLang)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
add_executable(crossapp main.cpp)
|
|
||||||
if(CROSSAPPPUBLISH_STATIC)
|
|
||||||
target_link_libraries(crossapp PUBLIC crosslang_static)
|
|
||||||
else()
|
|
||||||
install(TARGETS crossapp DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
|
||||||
|
|
||||||
target_link_libraries(crossapp PUBLIC crosslang_shared)
|
|
||||||
|
|
||||||
endif()
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
#include <CrossLang.hpp>
|
|
||||||
using namespace Tesses::Framework;
|
|
||||||
using namespace Tesses::CrossLang;
|
|
||||||
int main(int argc, char** argv)
|
|
||||||
{
|
|
||||||
TF_InitWithConsole();
|
|
||||||
if(argc > 0)
|
|
||||||
TF_AllowPortable(argv[0]);
|
|
||||||
std::string name = argv[0];
|
|
||||||
Tesses::Framework::Filesystem::VFSPath exePath=Tesses::Framework::Filesystem::LocalFS->SystemToVFSPath(name);
|
|
||||||
exePath.MakeAbsolute();
|
|
||||||
exePath.ChangeExtension(".crvm");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GC gc;
|
|
||||||
gc.Start();
|
|
||||||
GCList ls(gc);
|
|
||||||
TRootEnvironment* env = TRootEnvironment::Create(ls, TDictionary::Create(ls));
|
|
||||||
|
|
||||||
TStd::RegisterStd(&gc,env);
|
|
||||||
env->LoadFileWithDependencies(&gc, Tesses::Framework::Filesystem::LocalFS, exePath);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(env->HasVariable("WebAppMain"))
|
|
||||||
{
|
|
||||||
Args args(argc, argv);
|
|
||||||
int port = 4206;
|
|
||||||
for(auto& item : args.options)
|
|
||||||
{
|
|
||||||
if(item.first == "port")
|
|
||||||
{
|
|
||||||
port = std::stoi(item.second);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
env->EnsureDictionary(&gc,"Net")->SetValue("WebServerPort", (int64_t)port);
|
|
||||||
TList* args2 = TList::Create(ls);
|
|
||||||
args2->Add(exePath.ToString());
|
|
||||||
for(auto& item : args.positional)
|
|
||||||
{
|
|
||||||
args2->Add(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto res = env->CallFunctionWithFatalError(ls, "WebAppMain", {args2});
|
|
||||||
auto svr2 = Tesses::CrossLang::ToHttpServer(&gc,res);
|
|
||||||
if(svr2 == nullptr) return 1;
|
|
||||||
Tesses::Framework::Http::HttpServer svr(port,svr2);
|
|
||||||
svr.StartAccepting();
|
|
||||||
TF_RunEventLoop();
|
|
||||||
TDictionary* _dict;
|
|
||||||
TClassObject* _co;
|
|
||||||
if(GetObjectHeap(res,_dict))
|
|
||||||
{
|
|
||||||
_dict->CallMethod(ls,"Close",{});
|
|
||||||
}
|
|
||||||
if(GetObjectHeap(res,_co))
|
|
||||||
{
|
|
||||||
_co->CallMethod(ls,"","Close",{});
|
|
||||||
}
|
|
||||||
TF_Quit();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
TList* args = TList::Create(ls);
|
|
||||||
args->Add(exePath.ToString());
|
|
||||||
for(int arg=1;arg<argc;arg++)
|
|
||||||
args->Add(argv[arg]);
|
|
||||||
auto res = env->CallFunctionWithFatalError(ls,"main",{args});
|
|
||||||
int64_t iresult;
|
|
||||||
if(GetObject(res,iresult))
|
|
||||||
return (int)iresult;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 3.16)
|
|
||||||
|
|
||||||
project(CrossLangWii)
|
|
||||||
|
|
||||||
|
|
||||||
set(TESSESFRAMEWORK_FETCHCONTENT OFF CACHE INTERNAL "For TessesFramework" FORCE)
|
|
||||||
set(TESSESFRAMEWORK_ENABLE_RPATH OFF CACHE INTERNAL "For TessesFramework" FORCE)
|
|
||||||
set(TESSESFRAMEWORK_ENABLE_STATIC ON CACHE INTERNAL "For TessesFramework" FORCE)
|
|
||||||
set(TESSESFRAMEWORK_ENABLE_EXAMPLES OFF CACHE INTERNAL "For TessesFramework" FORCE)
|
|
||||||
set(TESSESFRAMEWORK_ENABLE_APPS OFF CACHE INTERNAL "For TessesFramework" FORCE)
|
|
||||||
set(TESSESFRAMEWORK_ENABLE_SHARED OFF CACHE INTERNAL "For TessesFramework" FORCE)
|
|
||||||
set(CROSSLANG_ENABLE_BINARIES OFF CACHE INTERNAL "For CrossLang" FORCE)
|
|
||||||
set(MBEDTLS_DIR "/opt/devkitpro/portlibs/wii" CACHE INTERNAL "For TessesFramework" FORCE)
|
|
||||||
|
|
||||||
include(FetchContent)
|
|
||||||
|
|
||||||
FetchContent_Declare(
|
|
||||||
TessesCrossLang
|
|
||||||
GIT_REPOSITORY https://onedev.site.tesses.net/crosslang.git
|
|
||||||
)
|
|
||||||
|
|
||||||
FetchContent_MakeAvailable(TessesCrossLang)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
add_executable(boot main.cpp)
|
|
||||||
target_link_libraries(boot PUBLIC crosslang_static)
|
|
||||||
ogc_create_dol(boot)
|
|
||||||
@@ -1,80 +0,0 @@
|
|||||||
#include <CrossLang.hpp>
|
|
||||||
using namespace Tesses::Framework;
|
|
||||||
using namespace Tesses::CrossLang;
|
|
||||||
int main(int argc, char** argv)
|
|
||||||
{
|
|
||||||
TF_InitWithConsole();
|
|
||||||
std::string name = "boot.dol";
|
|
||||||
Tesses::Framework::Filesystem::VFSPath exePath=Tesses::Framework::Filesystem::LocalFS->SystemToVFSPath(name);
|
|
||||||
exePath.MakeAbsolute();
|
|
||||||
exePath.ChangeExtension(".crvm");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GC gc;
|
|
||||||
gc.Start();
|
|
||||||
GCList ls(gc);
|
|
||||||
TRootEnvironment* env = TRootEnvironment::Create(ls, TDictionary::Create(ls));
|
|
||||||
|
|
||||||
TStd::RegisterStd(&gc,env);
|
|
||||||
env->LoadFileWithDependencies(&gc, Tesses::Framework::Filesystem::LocalFS, exePath);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(env->HasVariable("WebAppMain"))
|
|
||||||
{
|
|
||||||
std::vector<std::string> argsls={"boot.dol"};
|
|
||||||
for(int i = 0; i < argc; i++)
|
|
||||||
{
|
|
||||||
argsls.push_back(argv[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
Args args(argsls);
|
|
||||||
int port = 4206;
|
|
||||||
for(auto& item : args.options)
|
|
||||||
{
|
|
||||||
if(item.first == "port")
|
|
||||||
{
|
|
||||||
port = std::stoi(item.second);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
env->EnsureDictionary(&gc,"Net")->SetValue("WebServerPort", (int64_t)port);
|
|
||||||
TList* args2 = TList::Create(ls);
|
|
||||||
args2->Add(exePath.ToString());
|
|
||||||
for(auto& item : args.positional)
|
|
||||||
{
|
|
||||||
args2->Add(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto res = env->CallFunctionWithFatalError(ls, "WebAppMain", {args2});
|
|
||||||
auto svr2 = Tesses::CrossLang::ToHttpServer(&gc,res);
|
|
||||||
if(svr2 == nullptr) return 1;
|
|
||||||
Tesses::Framework::Http::HttpServer svr(port,svr2);
|
|
||||||
svr.StartAccepting();
|
|
||||||
TF_RunEventLoop();
|
|
||||||
TDictionary* _dict;
|
|
||||||
TClassObject* _co;
|
|
||||||
if(GetObjectHeap(res,_dict))
|
|
||||||
{
|
|
||||||
_dict->CallMethod(ls,"Close",{});
|
|
||||||
}
|
|
||||||
if(GetObjectHeap(res,_co))
|
|
||||||
{
|
|
||||||
_co->CallMethod(ls,"","Close",{});
|
|
||||||
}
|
|
||||||
TF_Quit();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
TList* args = TList::Create(ls);
|
|
||||||
args->Add(exePath.ToString());
|
|
||||||
for(int arg=0;arg<argc;arg++)
|
|
||||||
args->Add(argv[arg]);
|
|
||||||
auto res = env->CallFunctionWithFatalError(ls,"main",{args});
|
|
||||||
int64_t iresult;
|
|
||||||
if(GetObject(res,iresult))
|
|
||||||
return (int)iresult;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
set(CMAKE_C_COMPILER "/usr/bin/x86_64-w64-mingw32-gcc")
|
|
||||||
set(CMAKE_CXX_COMPILER "/usr/bin/x86_64-w64-mingw32-g++")
|
|
||||||
set(CMAKE_C_FLAGS "-static-libgcc -static-libstdc++ -static")
|
|
||||||
set(CMAKE_CXX_FLAGS "-static-libgcc -static-libstdc++ -static")
|
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static")
|
|
||||||
set(CMAKE_SYSTEM_NAME Windows)
|
|
||||||
set(CMAKE_SYSTEM_PROCESSOR x86_64)
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
set(CMAKE_C_COMPILER "/usr/bin/i686-w64-mingw32-gcc")
|
|
||||||
set(CMAKE_CXX_COMPILER "/usr/bin/i686-w64-mingw32-g++")
|
|
||||||
set(CMAKE_C_FLAGS "-static-libgcc -static-libstdc++ -static")
|
|
||||||
set(CMAKE_CXX_FLAGS "-static-libgcc -static-libstdc++ -static")
|
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static")
|
|
||||||
set(CMAKE_SYSTEM_NAME Windows)
|
|
||||||
set(CMAKE_SYSTEM_PROCESSOR i686)
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
rm -r compilers
|
|
||||||
mkdir -p compilers
|
|
||||||
cd compilers
|
|
||||||
wget https://downloads.tesses.net/cache/compilers/$1-cross.tgz
|
|
||||||
tar xvzf $1-cross.tgz
|
|
||||||
mv $1-cross/* .
|
|
||||||
rmdir $1-cross
|
|
||||||
rm $1-cross.tgz
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
mkdir compilers
|
|
||||||
crossint pack.tcross
|
|
||||||
@@ -1,282 +0,0 @@
|
|||||||
var VERSION="1.0.0.0-dev";
|
|
||||||
var statics = [
|
|
||||||
{
|
|
||||||
target="powerpc-linux-musl",
|
|
||||||
cpu = "powerpc"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
target="powerpc64-linux-musl",
|
|
||||||
cpu = "powerpc64"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
target="i686-linux-musl",
|
|
||||||
cpu = "i686"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
target="arm-linux-musleabihf",
|
|
||||||
cpu="armv7l"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
target="riscv32-linux-musl",
|
|
||||||
cpu="riscv32"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
target="riscv64-linux-musl",
|
|
||||||
cpu="riscv64"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
target="x86_64-linux-musl",
|
|
||||||
cpu="x86_64"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
target="mips-linux-musl",
|
|
||||||
cpu="mips"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
target="mips64-linux-musl",
|
|
||||||
cpu="mips64"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
target="aarch64-linux-musl",
|
|
||||||
cpu="aarch64"
|
|
||||||
}
|
|
||||||
|
|
||||||
];
|
|
||||||
|
|
||||||
func CPUS()
|
|
||||||
{
|
|
||||||
var p = Process.Start({
|
|
||||||
FileName = Env.GetRealExecutablePath("nproc").ToString(),
|
|
||||||
RedirectStandardOutput=true
|
|
||||||
});
|
|
||||||
var ms = new MemoryStream(true);
|
|
||||||
p.StandardOutput.CopyTo(ms);
|
|
||||||
return ParseLong(ms.GetBytes().ToString().Replace("\n","").Replace("\r",""));
|
|
||||||
}
|
|
||||||
var nproc = CPUS();
|
|
||||||
func BuildConsoleOrServerWindowsStatic(arch)
|
|
||||||
{
|
|
||||||
Console.WriteLine($"Building Windows Static {arch}");
|
|
||||||
var build_dir = "builds" / $"win-{arch}";
|
|
||||||
var publish_dir = "publish" / $"win-{arch}";
|
|
||||||
FS.Local.CreateDirectory(build_dir);
|
|
||||||
FS.Local.CreateDirectory(publish_dir);
|
|
||||||
|
|
||||||
var args = ["-S","ConsoleOrServer","-B",build_dir.ToString(),"-DCROSSAPPPUBLISH_STATIC=ON"];
|
|
||||||
|
|
||||||
var file= ("WindowsToolchains"/$"{arch}.cmake").MakeAbsolute().ToString();
|
|
||||||
|
|
||||||
args.Add($"-DCMAKE_TOOLCHAIN_FILE={file}");
|
|
||||||
|
|
||||||
Process.Start({
|
|
||||||
FileName = Env.GetRealExecutablePath("cmake").ToString(),
|
|
||||||
Arguments = args
|
|
||||||
}).Join();
|
|
||||||
|
|
||||||
|
|
||||||
var p = new Process();
|
|
||||||
p.FileName = Env.GetRealExecutablePath("make").ToString();
|
|
||||||
p.WorkingDirectory = build_dir.MakeAbsolute().ToString();
|
|
||||||
p.Arguments = [$"-j{nproc}"];
|
|
||||||
if(p.Start())
|
|
||||||
p.Join();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
func BuildConsoleOrServerLinuxStatic(dir,cmake_toolchain)
|
|
||||||
{
|
|
||||||
Console.WriteLine($"Building Linux Static {dir}");
|
|
||||||
var build_dir = "builds" / $"linux-{dir}-static";
|
|
||||||
var publish_dir = "publish" / $"linux-{dir}-static";
|
|
||||||
FS.Local.CreateDirectory(build_dir);
|
|
||||||
FS.Local.CreateDirectory(publish_dir);
|
|
||||||
|
|
||||||
var args = ["-S","ConsoleOrServer","-B",build_dir.ToString(),"-DCROSSAPPPUBLISH_STATIC=ON"];
|
|
||||||
if(TypeOf(cmake_toolchain) == "String")
|
|
||||||
{
|
|
||||||
args.Add($"-DCMAKE_TOOLCHAIN_FILE={cmake_toolchain}");
|
|
||||||
}
|
|
||||||
Process.Start({
|
|
||||||
FileName = Env.GetRealExecutablePath("cmake").ToString(),
|
|
||||||
Arguments = args
|
|
||||||
}).Join();
|
|
||||||
|
|
||||||
|
|
||||||
var p = new Process();
|
|
||||||
p.FileName = Env.GetRealExecutablePath("make").ToString();
|
|
||||||
p.WorkingDirectory = build_dir.MakeAbsolute().ToString();
|
|
||||||
p.Arguments = [$"-j{nproc}"];
|
|
||||||
if(p.Start())
|
|
||||||
p.Join();
|
|
||||||
|
|
||||||
|
|
||||||
mvFile(build_dir/"crossapp", publish_dir / "crossapp");
|
|
||||||
var info = {
|
|
||||||
type = "archive",
|
|
||||||
maintainer = "Mike Nolan",
|
|
||||||
repo = "https://onedev.site.tesses.net/crosslang",
|
|
||||||
homepage = "https://crosslang.tesseslanguage.com/",
|
|
||||||
executable_name = "crossapp",
|
|
||||||
executable_can_be_renamed = true,
|
|
||||||
executable_runtime = $"linux-{dir}-static",
|
|
||||||
description = $"Runtime files for linux-{dir}-static",
|
|
||||||
};
|
|
||||||
|
|
||||||
var name = $"Tesses.CrossLang.Runtime.linux-{dir}-static";
|
|
||||||
|
|
||||||
var subDir = new SubdirFilesystem(FS.Local,publish_dir);
|
|
||||||
var pkgStrm = FS.Local.OpenFile("publish"/$"{name}-{VERSION}.crvm","wb");
|
|
||||||
FS.CreateArchive(subDir,pkgStrm, name ,VERSION, Json.Encode(info));
|
|
||||||
pkgStrm.Close();
|
|
||||||
}
|
|
||||||
func BuildConsoleOrServerLinuxStaticBasedOnTarget(target,cpu)
|
|
||||||
{
|
|
||||||
var compiler = ("compilers"/"bin"/target).MakeAbsolute().ToString();
|
|
||||||
var p = new Process();
|
|
||||||
p.FileName = Env.GetRealExecutablePath("bash").ToString();
|
|
||||||
p.Arguments = ["extract_compiler.sh",target];
|
|
||||||
if(p.Start())
|
|
||||||
p.Join();
|
|
||||||
|
|
||||||
var toolchain = $"
|
|
||||||
set(CMAKE_C_COMPILER \"{compiler}-gcc\")
|
|
||||||
set(CMAKE_CXX_COMPILER \"{compiler}-g++\")
|
|
||||||
set(CMAKE_C_FLAGS \"-static-libgcc -static-libstdc++ -static\")
|
|
||||||
set(CMAKE_CXX_FLAGS \"-static-libgcc -static-libstdc++ -static\")
|
|
||||||
set(CMAKE_EXE_LINKER_FLAGS \"-static-libgcc -static-libstdc++ -static\")
|
|
||||||
|
|
||||||
|
|
||||||
set(CMAKE_SYSTEM_NAME Linux)
|
|
||||||
set(CMAKE_SYSTEM_PROCESSOR {cpu})
|
|
||||||
";
|
|
||||||
if(target == "riscv32-linux-musl" || target == "riscv64-linux-musl")
|
|
||||||
{
|
|
||||||
toolchain += "set(CMAKE_POSITION_INDEPENDENT_CODE ON)\n";
|
|
||||||
}
|
|
||||||
FS.WriteAllText(FS.Local,"compilers"/$"{target}.cmake", toolchain);
|
|
||||||
BuildConsoleOrServerLinuxStatic(cpu,("compilers"/$"{target}.cmake").MakeAbsolute().ToString());
|
|
||||||
}
|
|
||||||
func BuildConsoleOrServerLinuxShared(dir,$cmake_toolchain)
|
|
||||||
{
|
|
||||||
Console.WriteLine($"Building Linux Shared {dir}");
|
|
||||||
var build_dir = "builds" / $"linux-{dir}";
|
|
||||||
var publish_dir = "publish" / $"linux-{dir}";
|
|
||||||
FS.Local.CreateDirectory(build_dir);
|
|
||||||
FS.Local.CreateDirectory(publish_dir);
|
|
||||||
|
|
||||||
var args = ["-S","ConsoleOrServer","-B",build_dir.ToString()];
|
|
||||||
if(TypeOf(cmake_toolchain) == "String")
|
|
||||||
{
|
|
||||||
args.Add($"-DCMAKE_TOOLCHAIN_FILE={cmake_toolchain}");
|
|
||||||
}
|
|
||||||
Process.Start({
|
|
||||||
FileName = Env.GetRealExecutablePath("cmake").ToString(),
|
|
||||||
Arguments = args
|
|
||||||
}).Join();
|
|
||||||
|
|
||||||
|
|
||||||
var p = new Process();
|
|
||||||
p.FileName = Env.GetRealExecutablePath("make").ToString();
|
|
||||||
p.WorkingDirectory = build_dir.MakeAbsolute().ToString();
|
|
||||||
p.Arguments = [$"-j{nproc}"];
|
|
||||||
if(p.Start())
|
|
||||||
p.Join();
|
|
||||||
p = new Process();
|
|
||||||
p.FileName = Env.GetRealExecutablePath("make").ToString();
|
|
||||||
p.WorkingDirectory = build_dir.MakeAbsolute().ToString();
|
|
||||||
p.Arguments = ["install","DESTDIR=."];
|
|
||||||
if(p.Start())
|
|
||||||
p.Join();
|
|
||||||
|
|
||||||
mvFile(build_dir/"dir"/"crossapp", publish_dir / "crossapp");
|
|
||||||
each(var lib : FS.Local.EnumeratePaths(build_dir/"dir"))
|
|
||||||
{
|
|
||||||
if(lib.GetExtension() == ".so")
|
|
||||||
{
|
|
||||||
mvFile(lib,publish_dir / lib.GetFileName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var info = {
|
|
||||||
type = "archive",
|
|
||||||
maintainer = "Mike Nolan",
|
|
||||||
repo = "https://onedev.site.tesses.net/crosslang",
|
|
||||||
homepage = "https://crosslang.tesseslanguage.com/",
|
|
||||||
description = $"Runtime files for linux-{dir}",
|
|
||||||
executable_name = "crossapp",
|
|
||||||
executable_can_be_renamed = true,
|
|
||||||
executable_runtime = $"linux-{dir}"
|
|
||||||
};
|
|
||||||
|
|
||||||
var name = $"Tesses.CrossLang.Runtime.linux-{dir}";
|
|
||||||
|
|
||||||
var subDir = new SubdirFilesystem(FS.Local,publish_dir);
|
|
||||||
var pkgStrm = FS.Local.OpenFile("publish"/$"{name}-{VERSION}.crvm","wb");
|
|
||||||
FS.CreateArchive(subDir,pkgStrm, name ,VERSION, Json.Encode(info));
|
|
||||||
pkgStrm.Close();
|
|
||||||
}
|
|
||||||
func mvFile(src,dest)
|
|
||||||
{
|
|
||||||
Process.Start({
|
|
||||||
FileName = Env.GetRealExecutablePath("mv").ToString(),
|
|
||||||
Arguments = [src.MakeAbsolute().ToString(),dest.MakeAbsolute().ToString()]
|
|
||||||
}).Join();
|
|
||||||
}
|
|
||||||
func main(args)
|
|
||||||
{
|
|
||||||
Console.WriteLine($"Got {nproc} cpus");
|
|
||||||
each(var arch : ["x86","x64"])
|
|
||||||
{
|
|
||||||
var build_dir = "build" / $"win-{arch}";
|
|
||||||
var publish_dir = "publish" / $"win-{arch}";
|
|
||||||
FS.Local.CreateDirectory(publish_dir);
|
|
||||||
mvFile(build_dir/"crossapp.exe", publish_dir / "crossapp.exe");
|
|
||||||
var info = {
|
|
||||||
type = "archive",
|
|
||||||
maintainer = "Mike Nolan",
|
|
||||||
repo = "https://onedev.site.tesses.net/crosslang",
|
|
||||||
homepage = "https://crosslang.tesseslanguage.com/",
|
|
||||||
executable_name = "crossapp.exe",
|
|
||||||
executable_can_be_renamed = true,
|
|
||||||
executable_runtime = $"win-{arch}",
|
|
||||||
description = $"Runtime files for win-{arch}",
|
|
||||||
};
|
|
||||||
|
|
||||||
var name = $"Tesses.CrossLang.Runtime.win-{arch}";
|
|
||||||
|
|
||||||
var subDir = new SubdirFilesystem(FS.Local,publish_dir);
|
|
||||||
var pkgStrm = FS.Local.OpenFile("publish"/$"{name}-{VERSION}.crvm","wb");
|
|
||||||
FS.CreateArchive(subDir,pkgStrm, name ,VERSION, Json.Encode(info));
|
|
||||||
pkgStrm.Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
BuildConsoleOrServerLinuxShared("x86_64");
|
|
||||||
BuildConsoleOrServerLinuxShared("aarch64", "/opt/toolchains/arm64.cmake");
|
|
||||||
BuildConsoleOrServerLinuxShared("armv7l", "/opt/toolchains/armhf.cmake");
|
|
||||||
BuildConsoleOrServerLinuxShared("riscv64", "/opt/toolchains/riscv64.cmake");
|
|
||||||
|
|
||||||
|
|
||||||
each(var static : statics)
|
|
||||||
{
|
|
||||||
BuildConsoleOrServerLinuxStaticBasedOnTarget(static.target,static.cpu);
|
|
||||||
}
|
|
||||||
|
|
||||||
var info = {
|
|
||||||
type = "archive",
|
|
||||||
maintainer = "Mike Nolan",
|
|
||||||
repo = "https://onedev.site.tesses.net/crosslang",
|
|
||||||
homepage = "https://crosslang.tesseslanguage.com/",
|
|
||||||
executable_name = "boot.dol",
|
|
||||||
executable_can_be_renamed = false,
|
|
||||||
executable_runtime = "wii",
|
|
||||||
description = $"Runtime files for wii",
|
|
||||||
};
|
|
||||||
|
|
||||||
var name = $"Tesses.CrossLang.Runtime.wii";
|
|
||||||
|
|
||||||
var subDir = new SubdirFilesystem(FS.Local,"publish"/"wii");
|
|
||||||
var pkgStrm = FS.Local.OpenFile("publish"/$"{name}-{VERSION}.crvm","wb");
|
|
||||||
FS.CreateArchive(subDir,pkgStrm, name ,VERSION, Json.Encode(info));
|
|
||||||
pkgStrm.Close();
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
bash ./pack.sh
|
|
||||||
bash ./publish.sh
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
find publish -name "*.crvm" -exec crosslang upload-package --token="$CPKG_KEY" --host="https://cpkg.tesseslanguage.com/" "{}" \;
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
mkdir -p publish/wii
|
|
||||||
cd Wii
|
|
||||||
mkdir build
|
|
||||||
cd build
|
|
||||||
cmake -S .. -B . -DCMAKE_TOOLCHAIN_FILE=/opt/devkitpro/cmake/Wii.cmake
|
|
||||||
make -j`nproc`
|
|
||||||
mv boot.dol ../../publish/wii/boot.dol
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
echo "Building Windows Static x86"
|
|
||||||
cmake -S "ConsoleOrServer" -B build/win-x86 -DCROSSAPPPUBLISH_STATIC=ON -DCMAKE_TOOLCHAIN_FILE=`pwd`/WindowsToolchains/x86.cmake
|
|
||||||
cd build/win-x86
|
|
||||||
make -j`nproc`
|
|
||||||
cd ../..
|
|
||||||
echo "Building Windows Static x64"
|
|
||||||
cmake -S "ConsoleOrServer" -B build/win-x64 -DCROSSAPPPUBLISH_STATIC=ON -DCMAKE_TOOLCHAIN_FILE=`pwd`/WindowsToolchains/x64.cmake
|
|
||||||
cd build/win-x64
|
|
||||||
make -j`nproc`
|
|
||||||
cd ../..
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
# Maintainer: Mike Nolan <tesses@tesses.net>
|
# Maintainer: Mike Nolan <tesses@tesses.net>
|
||||||
pkgname=crosslang # '-bzr', '-git', '-hg' or '-svn'
|
pkgname=crosslang # '-bzr', '-git', '-hg' or '-svn'
|
||||||
pkgver=1.0.0
|
pkgver=0.0.1
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
pkgdesc=""
|
pkgdesc=""
|
||||||
arch=('x86_64' 'powerpc')
|
arch=('x86_64' 'powerpc')
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
export BUILD=$(($BUILD_NO-142))
|
export BUILD=$(($BUILD_NO-152))
|
||||||
export DEB_VERSION=1.0.0-$BUILD
|
export DEB_VERSION=0.0.1-$BUILD
|
||||||
@@ -1 +0,0 @@
|
|||||||
# C++ Layer
|
|
||||||
@@ -1,232 +0,0 @@
|
|||||||
Extending the runtime
|
|
||||||
=====================
|
|
||||||
|
|
||||||
See [this](CPP_LAYER.md)
|
|
||||||
|
|
||||||
There are a couple ways of doing this
|
|
||||||
|
|
||||||
- Creating a shared library (only works if using shared libs)
|
|
||||||
- Embeding the runtime
|
|
||||||
- Forking crosslang and adding functionality (I don't support pull requests at this time)
|
|
||||||
|
|
||||||
### Shared Library
|
|
||||||
|
|
||||||
This assumes you are on linux, if on windows use MyPlugin.dll on mac libMyPlugin.dylib in crosslang project (it would be a good idea to check Env.Platform)
|
|
||||||
|
|
||||||
CMakeLists.txt:
|
|
||||||
```cmake
|
|
||||||
cmake_minimum_required(VERSION 3.16)
|
|
||||||
|
|
||||||
project(MyPlugin)
|
|
||||||
|
|
||||||
find_package(TessesCrossLang REQUIRED)
|
|
||||||
|
|
||||||
add_library(MyPlugin SHARED lib.cpp)
|
|
||||||
|
|
||||||
target_link_libraries(MyPlugin PUBLIC TessesCrossLang::crosslang_shared)
|
|
||||||
```
|
|
||||||
|
|
||||||
lib.cpp:
|
|
||||||
```c++
|
|
||||||
#include <CrossLang.hpp>
|
|
||||||
|
|
||||||
using namespace Tesses::CrossLang;
|
|
||||||
|
|
||||||
void MyPlugin(GC* gc, TRootEnvironment* env)
|
|
||||||
{
|
|
||||||
GCList ls(gc);
|
|
||||||
TDictionary* dict = TDictionary::Create(ls,{
|
|
||||||
TDItem("MyFunction", TExternalMethod::Create(ls, "A description for function",{"myLong","$optionalList"},[](GCList& ls, std::vector<TObject> args)->TObject {
|
|
||||||
int64_t n;
|
|
||||||
if(GetArgument(args,0,n))
|
|
||||||
{
|
|
||||||
TList* myLs;
|
|
||||||
if(GetArgumentHeap(args,1,myLs))
|
|
||||||
{
|
|
||||||
//do something with the list
|
|
||||||
myLs->Add(n);
|
|
||||||
return TList::Create(ls, {n,myLs});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return TList::Create(ls, {n});
|
|
||||||
}
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}))
|
|
||||||
});
|
|
||||||
|
|
||||||
gc->BarrierBegin();
|
|
||||||
env->SetVariable("MyPlugin",dict);
|
|
||||||
gc->BarrierEnd();
|
|
||||||
}
|
|
||||||
|
|
||||||
CROSSLANG_PLUGIN(MyPlugin);
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
main.tcross:
|
|
||||||
```go
|
|
||||||
func main(args)
|
|
||||||
{
|
|
||||||
Reflection.LoadNativePlugin(FS.MakeFull("libMyPlugin.so"));
|
|
||||||
|
|
||||||
var res = MyPlugin.MyFunction(42);
|
|
||||||
if(TypeOf(res) == "List")
|
|
||||||
{
|
|
||||||
Console.WriteLine(res);
|
|
||||||
}
|
|
||||||
|
|
||||||
var res = MyPlugin.MyFunction(42,["Hello","John"]);
|
|
||||||
if(TypeOf(res) == "List")
|
|
||||||
{
|
|
||||||
Console.WriteLine(res);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
### Embeding the runtime
|
|
||||||
|
|
||||||
CMakeLists.txt:
|
|
||||||
```cmake
|
|
||||||
cmake_minimum_required(VERSION 3.16)
|
|
||||||
|
|
||||||
project(MyCrossLangBinary)
|
|
||||||
|
|
||||||
find_package(TessesCrossLang REQUIRED)
|
|
||||||
|
|
||||||
add_executable(MyCrossLangBinary SHARED app.cpp)
|
|
||||||
|
|
||||||
target_link_libraries(MyCrossLangBinary PUBLIC TessesCrossLang::crosslang_shared) # or crosslang_static for static linking
|
|
||||||
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
app.cpp:
|
|
||||||
```c++
|
|
||||||
#include <CrossLang.hpp>
|
|
||||||
|
|
||||||
using namespace Tesses::CrossLang;
|
|
||||||
using namespace Tesses::Framework;
|
|
||||||
|
|
||||||
void MyPlugin(GC* gc, TRootEnvironment* env)
|
|
||||||
{
|
|
||||||
GCList ls(gc);
|
|
||||||
TDictionary* dict = TDictionary::Create(ls,{
|
|
||||||
TDItem("MyFunction", TExternalMethod::Create(ls, "A description for function",{"myLong","$optionalList"},[](GCList& ls, std::vector<TObject> args)->TObject {
|
|
||||||
int64_t n;
|
|
||||||
if(GetArgument(args,0,n))
|
|
||||||
{
|
|
||||||
TList* myLs;
|
|
||||||
if(GetArgumentHeap(args,1,myLs))
|
|
||||||
{
|
|
||||||
//do something with the list
|
|
||||||
myLs->Add(n);
|
|
||||||
return TList::Create(ls, {n,myLs});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return TList::Create(ls, {n});
|
|
||||||
}
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}))
|
|
||||||
});
|
|
||||||
|
|
||||||
gc->BarrierBegin();
|
|
||||||
env->SetVariable("MyPlugin",dict);
|
|
||||||
gc->BarrierEnd();
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
|
||||||
{
|
|
||||||
TF_Init();
|
|
||||||
if(argc < 2)
|
|
||||||
{
|
|
||||||
printf("USAGE: %s <filename.crvm> <args...>\n",argv[0]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
GC gc;
|
|
||||||
gc.RegisterEverythingCallback(MyPlugin);
|
|
||||||
gc.Start();
|
|
||||||
GCList ls(gc);
|
|
||||||
TRootEnvironment* env = TRootEnvironment::Create(ls,TDictionary::Create(ls));
|
|
||||||
Tesses::Framework::Filesystem::LocalFilesystem fs;
|
|
||||||
TStd::RegisterStd(&gc,env);
|
|
||||||
env->LoadFileWithDependencies(&gc, &fs, fs.SystemToVFSPath(argv[1]));
|
|
||||||
|
|
||||||
TList* args = TList::Create(ls);
|
|
||||||
for(int arg=1;arg<argc;arg++)
|
|
||||||
args->Add(std::string(argv[arg]));
|
|
||||||
|
|
||||||
auto res = env->CallFunction(ls,"main",{args});
|
|
||||||
int64_t iresult;
|
|
||||||
if(GetObject(res,iresult))
|
|
||||||
return (int)iresult;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
main.tcross (needs to be compiled with crossc):
|
|
||||||
```go
|
|
||||||
func main(args)
|
|
||||||
{
|
|
||||||
//no reflection necessary
|
|
||||||
|
|
||||||
var res = MyPlugin.MyFunction(42);
|
|
||||||
if(TypeOf(res) == "List")
|
|
||||||
{
|
|
||||||
Console.WriteLine(res);
|
|
||||||
}
|
|
||||||
|
|
||||||
var res = MyPlugin.MyFunction(42,["Hello","John"]);
|
|
||||||
if(TypeOf(res) == "List")
|
|
||||||
{
|
|
||||||
Console.WriteLine(res);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Forking (implementing it in runtime library itself)
|
|
||||||
- edit include/CrossLang.hpp
|
|
||||||
- in TStd class insert, static void RegisterMyPlugin(GC* gc, TRootEnvironment* env); where MyPlugin is whatever you want
|
|
||||||
- edit src/runtime_methods/std.cpp
|
|
||||||
- in TStd::RegisterStd before register everything call TStd::RegisterMyPlugin(gc, env);
|
|
||||||
- in CMakeLists.txt within list(APPEND CROSSLANG_SOURCE **Many Source Files**) you must add src/runtime_methods/myplugin.cpp
|
|
||||||
|
|
||||||
src/runtime_methods/myplugin.cpp:
|
|
||||||
```c++
|
|
||||||
#include <CrossLang.hpp>
|
|
||||||
namespace Tesses::CrossLang
|
|
||||||
{
|
|
||||||
void TStd::RegisterMyPlugin(GC* gc, TRootEnvironment* env)
|
|
||||||
{
|
|
||||||
GCList ls(gc);
|
|
||||||
TDictionary* dict = TDictionary::Create(ls,{
|
|
||||||
TDItem("MyFunction", TExternalMethod::Create(ls, "A description for function",{"myLong","$optionalList"},[](GCList& ls, std::vector<TObject> args)->TObject {
|
|
||||||
int64_t n;
|
|
||||||
if(GetArgument(args,0,n))
|
|
||||||
{
|
|
||||||
TList* myLs;
|
|
||||||
if(GetArgumentHeap(args,1,myLs))
|
|
||||||
{
|
|
||||||
//do something with the list
|
|
||||||
myLs->Add(n);
|
|
||||||
return TList::Create(ls, {n,myLs});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return TList::Create(ls, {n});
|
|
||||||
}
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}))
|
|
||||||
});
|
|
||||||
|
|
||||||
gc->BarrierBegin();
|
|
||||||
env->SetVariable("MyPlugin",dict);
|
|
||||||
gc->BarrierEnd();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
598
docs/HANDBOOK.md
598
docs/HANDBOOK.md
@@ -1,598 +0,0 @@
|
|||||||
## CrossLang Handbook
|
|
||||||
|
|
||||||
This is a book for my language found [here](https://crosslang.tesseslanguage.com/)
|
|
||||||
|
|
||||||
## Statements and loops
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### Declare a variable (it is an expression)
|
|
||||||
|
|
||||||
You can (the var is optional but should be used if the root environment has the same variable and you don't want to set it)
|
|
||||||
|
|
||||||
```js
|
|
||||||
var myVariable = 42;
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Set a variable (it is an expression)
|
|
||||||
|
|
||||||
```js
|
|
||||||
myVariable = "I have set the variable to a string";
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Reflective variables
|
|
||||||
|
|
||||||
```js
|
|
||||||
var nameOfVariable = "Var 1";
|
|
||||||
.[nameOfVariable] = 42; //the variable name in this instance will be Var 1
|
|
||||||
Console.WriteLine(.[nameOfVariable]); //prints 42
|
|
||||||
|
|
||||||
|
|
||||||
var nameOfVariable2 = "Var 2";
|
|
||||||
var nameOfField = "This field has spaces and \n New Lines";
|
|
||||||
.[nameOfVariable2] = {
|
|
||||||
.[nameOfField] = "Hello, world"
|
|
||||||
};
|
|
||||||
|
|
||||||
Console.WriteLine(.[nameOfVariable2].[nameOfField]); //should print Hello, world
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
#### If statements
|
|
||||||
|
|
||||||
The {} are optional if you only need one statement
|
|
||||||
|
|
||||||
```js
|
|
||||||
var myExpression = 0;
|
|
||||||
var myOtherExpression = {
|
|
||||||
mol = 42
|
|
||||||
};
|
|
||||||
|
|
||||||
if(myExpression)
|
|
||||||
{
|
|
||||||
Console.WriteLine("myExpression is truthy");
|
|
||||||
}
|
|
||||||
else if(myOtherExpression)
|
|
||||||
{
|
|
||||||
//this will run based on the condition
|
|
||||||
Console.WriteLine("myExpression is falsey but myOtherExpression is truthy");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Console.WriteLine("both myExpression and myOtherExpression are falsey");
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
#### For loop
|
|
||||||
|
|
||||||
Note: i will leak, also you can use curly brackets like if
|
|
||||||
|
|
||||||
```js
|
|
||||||
for(var i = 0; i < 42; i++)
|
|
||||||
Console.WriteLine(i);
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Each loop
|
|
||||||
|
|
||||||
```js
|
|
||||||
enumerable MyItterator()
|
|
||||||
{
|
|
||||||
yield 42;
|
|
||||||
yield 100;
|
|
||||||
yield 88;
|
|
||||||
}
|
|
||||||
each(var item : MyItterator())
|
|
||||||
{
|
|
||||||
Console.WriteLine(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
each(var item : [3,7,12])
|
|
||||||
{
|
|
||||||
Console.WriteLine(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
This should output
|
|
||||||
42
|
|
||||||
100
|
|
||||||
88
|
|
||||||
3
|
|
||||||
7
|
|
||||||
12
|
|
||||||
*/
|
|
||||||
```
|
|
||||||
|
|
||||||
#### While loop
|
|
||||||
|
|
||||||
```js
|
|
||||||
while(conditionLikeIf)
|
|
||||||
{
|
|
||||||
Console.WriteLine("Hi");
|
|
||||||
}
|
|
||||||
|
|
||||||
//If conditionLikeIf is falsey we never print Hi
|
|
||||||
//If conditionLikeIf is truthy we print Hi until it is falsey
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Do loop
|
|
||||||
|
|
||||||
```js
|
|
||||||
do(conditionLikeIf)
|
|
||||||
{
|
|
||||||
Console.WriteLine("Hi");
|
|
||||||
}
|
|
||||||
|
|
||||||
//If conditionLikeIf is falsey we print Hi once
|
|
||||||
//If conditionLikeIf is truthy we print Hi until it is falsey
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### Try statement
|
|
||||||
|
|
||||||
NOTE: you can't return undefined (but you can return other types) (It will just return from try and will still execute the body past the try statement) due to the try statement being a closure (you can still break and continue due to special TObjects being returned)
|
|
||||||
|
|
||||||
```js
|
|
||||||
try {
|
|
||||||
Console.WriteLine("God is good.");
|
|
||||||
throw "my error";
|
|
||||||
Console.WriteLine("I am lonely, I am never called.");
|
|
||||||
}
|
|
||||||
catch(ex)
|
|
||||||
{
|
|
||||||
Console.WriteLine($"I got an error {ex}.");
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
Console.WriteLine("For God so loved the world that he gave his only begotten Son, that whoever believes in him should not perish but have eternal life.");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
This should print
|
|
||||||
God is good.
|
|
||||||
I got an error my error.
|
|
||||||
For God so loved the world that he gave his only begotten Son, that whoever believes in him should not perish but have eternal life.
|
|
||||||
*/
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Switch statement
|
|
||||||
|
|
||||||
NOTE: you can use dictionaries with overloaded equals operator (we will pass the switch's expression as the argument)
|
|
||||||
|
|
||||||
```js
|
|
||||||
o = {
|
|
||||||
operator== = (this,v) => {
|
|
||||||
//this is implicitly passed by runtime, but you must declare it if you want it
|
|
||||||
return (v * 7) == 42;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var val = 6;
|
|
||||||
|
|
||||||
switch(val)
|
|
||||||
{
|
|
||||||
case 4:
|
|
||||||
Console.WriteLine("I am four");
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
Console.WriteLine("I am five");
|
|
||||||
break;
|
|
||||||
case o:
|
|
||||||
Console.WriteLine("Hitchhiker's guide to the galaxy meaning of life");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
Console.WriteLine("We don't support it we are sorry");
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### Function declaration
|
|
||||||
|
|
||||||
```go
|
|
||||||
//you can create functions on dictionaries so long as they are on root environment (they are declared there before root scope is evaluated so this is possible)
|
|
||||||
My.Func.Joel = 59; //Because My.Func.Is.A.Few.Deep creates the dictionaries via runtime
|
|
||||||
|
|
||||||
func My.Func.Is.A.Few.Deep(a, b)
|
|
||||||
{
|
|
||||||
return a * b;
|
|
||||||
}
|
|
||||||
func main(args)
|
|
||||||
{
|
|
||||||
Console.WriteLine(My.Func.Is.A.Few.Deep(6,7));
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Function inside a function
|
|
||||||
|
|
||||||
Oh yeah functions can have exclusively a expression as a body which does not need a return keyword
|
|
||||||
|
|
||||||
```go
|
|
||||||
func main(args)
|
|
||||||
{
|
|
||||||
func MyOther(a,b) a * b;
|
|
||||||
Console.WriteLine(MyOther(a,b));
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Document a function
|
|
||||||
|
|
||||||
```go
|
|
||||||
/^
|
|
||||||
This function returns 42
|
|
||||||
^/
|
|
||||||
func MyFunction() 42;
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Return statement
|
|
||||||
|
|
||||||
You can also return nothing
|
|
||||||
|
|
||||||
```js
|
|
||||||
return 42;
|
|
||||||
return;
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Yield statement
|
|
||||||
|
|
||||||
This will halt the function's execution and return the running function object (were you can pop the item and resume it)
|
|
||||||
|
|
||||||
To automaticly make a function enumerable (with each statement) you must use ``enumerable`` instead of func when declaring your function
|
|
||||||
|
|
||||||
```js
|
|
||||||
yield 42;
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Throw statement
|
|
||||||
|
|
||||||
You can catch this with ``try statement`` with ``catch`` clause
|
|
||||||
|
|
||||||
```js
|
|
||||||
throw "You can replace me with another string or any other object";
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Defer statement
|
|
||||||
|
|
||||||
Your code will be called when your scope is destroyed
|
|
||||||
|
|
||||||
```go
|
|
||||||
{
|
|
||||||
defer {
|
|
||||||
Console.WriteLine("In defer");
|
|
||||||
}
|
|
||||||
Console.WriteLine("About to leave scope");
|
|
||||||
}
|
|
||||||
Console.WriteLine("Left scope");
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
The output should be
|
|
||||||
|
|
||||||
About to leave scope
|
|
||||||
In defer
|
|
||||||
Left scope
|
|
||||||
*/
|
|
||||||
```
|
|
||||||
|
|
||||||
## Expressions
|
|
||||||
|
|
||||||
We will place it as a parameter to a function ``doThing`` but these will work anywhere like setting a variable or another expression
|
|
||||||
|
|
||||||
#### Undefined
|
|
||||||
|
|
||||||
```js
|
|
||||||
doThing(undefined);
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Null
|
|
||||||
|
|
||||||
```js
|
|
||||||
doThing(null);
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Boolean
|
|
||||||
|
|
||||||
```js
|
|
||||||
doThing(false);
|
|
||||||
doThing(true);
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Long
|
|
||||||
|
|
||||||
A signed 64 bit number
|
|
||||||
|
|
||||||
```js
|
|
||||||
doThing(94);
|
|
||||||
doThing(599929022);
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Double
|
|
||||||
|
|
||||||
A 64 bit floating pointer number
|
|
||||||
|
|
||||||
```js
|
|
||||||
doThing(5.25);
|
|
||||||
doThing(942.90204);
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Char
|
|
||||||
|
|
||||||
Yes we support single character strings (this escapes a double quote)
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
doThing('\"');
|
|
||||||
```
|
|
||||||
|
|
||||||
#### String
|
|
||||||
|
|
||||||
Second is an interopolated string
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
doThing("Hi");
|
|
||||||
doThing($"My name is {name}");
|
|
||||||
```
|
|
||||||
|
|
||||||
#### List
|
|
||||||
|
|
||||||
```js
|
|
||||||
doThing(
|
|
||||||
[4,5,9,42,true,"Hi",'\n']
|
|
||||||
);
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Dictionary
|
|
||||||
|
|
||||||
```js
|
|
||||||
doThing(
|
|
||||||
{
|
|
||||||
a = "This is an option",
|
|
||||||
b = 42,
|
|
||||||
c = 9
|
|
||||||
}
|
|
||||||
);
|
|
||||||
```
|
|
||||||
|
|
||||||
###### Enumerating a dictionary
|
|
||||||
|
|
||||||
```js
|
|
||||||
var dict = { a = 5, b = 42};
|
|
||||||
each(var item : Dictionary.Items(dict))
|
|
||||||
{
|
|
||||||
Console.WriteLine($"Key: {item.Key}");
|
|
||||||
Console.WriteLine($"Value: {item.Value}");
|
|
||||||
Console.WriteLine();
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
This prints
|
|
||||||
Key: a
|
|
||||||
Value: 5
|
|
||||||
|
|
||||||
Key: b
|
|
||||||
Value: 42
|
|
||||||
|
|
||||||
*/
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
###### Getting a value from dictionary
|
|
||||||
|
|
||||||
```go
|
|
||||||
func doThing(data)
|
|
||||||
{
|
|
||||||
Console.WriteLine(data.b); //will print 42
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
###### Setting a value to dictionary
|
|
||||||
|
|
||||||
```go
|
|
||||||
func doThing(data)
|
|
||||||
{
|
|
||||||
data.a = true; //replace a with a different value
|
|
||||||
data.someFieldThatDoesNotExist = 9; //define a new field entirely
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
###### Methods
|
|
||||||
|
|
||||||
Note that this is optional but if you do have it it must be the first argument, the this argument points to the dictionary
|
|
||||||
|
|
||||||
```go
|
|
||||||
var item = {
|
|
||||||
myMethod = (this, a, b) => {
|
|
||||||
return a * b;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Console.WriteLine(item.myMethod(6,7)); //prints 42
|
|
||||||
```
|
|
||||||
|
|
||||||
Or
|
|
||||||
|
|
||||||
```go
|
|
||||||
var item = {};
|
|
||||||
func item.myMethod(this, a, b)
|
|
||||||
{
|
|
||||||
return a * b;
|
|
||||||
}
|
|
||||||
Console.WriteLine(item.myMethod(6,7)); //prints 42
|
|
||||||
```
|
|
||||||
|
|
||||||
###### Properties
|
|
||||||
|
|
||||||
They are declared like every other method except they are prefixed with ``get`` or ``set``
|
|
||||||
|
|
||||||
```go
|
|
||||||
var item = {
|
|
||||||
getProp = (this)=>{
|
|
||||||
return 42;
|
|
||||||
},
|
|
||||||
setProp = (this,v)=>{
|
|
||||||
//do something with v
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Console.WriteLine(item.Prop); //equivalent to Console.WriteLine(item.getProp());
|
|
||||||
|
|
||||||
item.Prop = 100; //equivalent to item.setProp(100); will do nothing in this example
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
###### Operator overloading
|
|
||||||
|
|
||||||
```js
|
|
||||||
var item = {
|
|
||||||
operator+ = (this,right) => {
|
|
||||||
return 4 + a;
|
|
||||||
}
|
|
||||||
operator- = (this,right) => {
|
|
||||||
return 4 - right; //be careful right may be undefined if the negate operator is used
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Console.WriteLine(item + 5); //prints 9
|
|
||||||
```
|
|
||||||
|
|
||||||
###### Array operator overloading
|
|
||||||
|
|
||||||
```js
|
|
||||||
var item = {
|
|
||||||
GetAt = (index)=>{
|
|
||||||
return index * 2; //we multiply index by two and return
|
|
||||||
},
|
|
||||||
SetAt => (index,value)=>{
|
|
||||||
Console.WriteLine($"The index was {index} and value was {value}");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Console.WriteLine(item[21]); //prints 42
|
|
||||||
item["Hi"] = "John"; //prints The index was Hi and value was John
|
|
||||||
```
|
|
||||||
|
|
||||||
#### ByteArray
|
|
||||||
|
|
||||||
```js
|
|
||||||
var bA = new ByteArray(1);
|
|
||||||
ba[0] = 42;
|
|
||||||
Console.WriteLine(ba.ToString()); //prints *
|
|
||||||
```
|
|
||||||
|
|
||||||
###### ByteArray from string
|
|
||||||
|
|
||||||
```js
|
|
||||||
var bA = new ByteArray("Hi");
|
|
||||||
//we can get bytes like this bA[0] which will be 72
|
|
||||||
//we can get length by bA.Count or bA.Length
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Embedding files (you can't do this easily in C/C++ and C# not as easy as this)
|
|
||||||
|
|
||||||
```js
|
|
||||||
var bA = embed("myFile.png"); //will embed the file res/myFile.png
|
|
||||||
//it is stored as a RESO in the crvm file and bA is a ByteArray
|
|
||||||
//note the argument MUST be a constant string
|
|
||||||
//note you can access a subdirectory of res as well just use dir/file.bin
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Streams
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
###### From an existing file
|
|
||||||
|
|
||||||
```js
|
|
||||||
var strm = FS.Local.OpenFile("file.bin","rb");
|
|
||||||
|
|
||||||
var data = new ByteArray(1024);
|
|
||||||
var read = strm.Read(data,0,data.Count);
|
|
||||||
//use ReadBlock to ensure you have 1024 bytes if not near end of stream
|
|
||||||
|
|
||||||
//use WriteBlock to ensure you write the amount you say you need
|
|
||||||
|
|
||||||
strm.Close();
|
|
||||||
```
|
|
||||||
|
|
||||||
#### VFS
|
|
||||||
|
|
||||||
```js
|
|
||||||
var myVFS = FS.Local; //FS.Local is the local filesystem
|
|
||||||
|
|
||||||
|
|
||||||
myVFS.CreateDirectory("myDir"); //creates directory in current dir (only local)
|
|
||||||
|
|
||||||
myVFS.DeleteDirectory("myDir"); //now we delete it
|
|
||||||
|
|
||||||
|
|
||||||
myVFS.CreateDirectory(Path.FromString(Env.Downloads) / "Folder in Downloads"); //Create a folder in downloads
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### Path
|
|
||||||
|
|
||||||
```js
|
|
||||||
var path = / "Path" / "To" / "Directory";
|
|
||||||
var relativePath = ./"another"/"path";
|
|
||||||
var combined = path / relativePath;
|
|
||||||
var someString = "joel";
|
|
||||||
var combinedAndStr = combined / someString;
|
|
||||||
var combinedWithExtension = combined + ".mp4";
|
|
||||||
Console.WriteLine(combined); // outputs /Path/To/Directory/another/path
|
|
||||||
Console.WriteLine(combined); // outputs /Path/To/Directory/another/path/joel
|
|
||||||
Console.WriteLine(combinedWithExtension); //outputs /Path/To/Directory/another/path.mp4
|
|
||||||
//these paths are used with vfs
|
|
||||||
|
|
||||||
|
|
||||||
//to get parent directory use combined.GetParent();
|
|
||||||
//to get filename use combined.GetFileName();
|
|
||||||
//to get extension use combinedWithExtension.GetExtension();, it will be the extension including .
|
|
||||||
//to change the extension use combinedWithExtension.ChangeExtension(".mkv");
|
|
||||||
//to remove the extension use combinedWithExtension.ChangeExtension(null); or combinedWithExtension.ChangeExtension();
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Html Litterals
|
|
||||||
```go
|
|
||||||
//comments are just crosslang ones
|
|
||||||
|
|
||||||
//we will be setting to myHtml for the html (returns a string) (it is already html escaped)
|
|
||||||
myHtml = <h1>{someStringExpression}</h1>;
|
|
||||||
|
|
||||||
//a link, in this example we have a dictionary named node with string fields href and text
|
|
||||||
//lets say node.text equaled List<int> and href contained ./mypage?name=Joel&file=steve.bin myHtml would be equal to "<a target=\"_blank\" href=\"./mypage?name=Joel&file=steve.bin\">List<int></a>" (the \ are just there to make this a valid string for demonstration purposes, there aren't really backslashes)
|
|
||||||
myHtml = <a target="_blank" href={node.href}>{node.text}</a>;
|
|
||||||
|
|
||||||
|
|
||||||
//for (works like for loop but is in html form, the for part is not rendered in the final string)
|
|
||||||
myHtml = <for(var i = 0; i < 42; i++)>
|
|
||||||
<h6>{i}</h6>
|
|
||||||
</for>;
|
|
||||||
|
|
||||||
//each
|
|
||||||
myHtml = <each(var item : list)></each>;
|
|
||||||
|
|
||||||
//do
|
|
||||||
myHtml = <do(expr == 42)></do>;
|
|
||||||
|
|
||||||
//while
|
|
||||||
myHtml = <while(expr == 42)></while>;
|
|
||||||
|
|
||||||
//if
|
|
||||||
|
|
||||||
myHtml = <if(expr == 42)>
|
|
||||||
<true>
|
|
||||||
//if expr is 42
|
|
||||||
</true>
|
|
||||||
<false>
|
|
||||||
//if expr is not 42
|
|
||||||
//you would use another if here instead of else if
|
|
||||||
</false>
|
|
||||||
</if>;
|
|
||||||
|
|
||||||
myHtml = <null>Hello</null>; //would just be Hello (useful for templating as it works just like div but the null part is not emited into string)
|
|
||||||
|
|
||||||
myHtml = <raw(stringExpr)>; //allowing you to emit unescaped html from string into html litteral (useful for templating)
|
|
||||||
```
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
# Tesses CrossLang
|
|
||||||
|
|
||||||
This is the docs for my language
|
|
||||||
|
|
||||||
- [Handbook](HANDBOOK.md)
|
|
||||||
- [C++ Layer](CPP_LAYER.md)
|
|
||||||
- [Extend the runtime](EXTENDING_RUNTIME.md)
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
What is TObject
|
|
||||||
===============
|
|
||||||
|
|
||||||
It is a std::variant that can be (not in that order)
|
|
||||||
|
|
||||||
- Undefined (std::monostate)
|
|
||||||
- Null (std::nullptr_t)
|
|
||||||
- Long (int64_t)
|
|
||||||
- Double (double)
|
|
||||||
- Char (char)
|
|
||||||
- String (std::string)
|
|
||||||
- Version (Tesses::CrossLang::TVMVersion)
|
|
||||||
- Regex (std::regex)
|
|
||||||
- Path (Tesses::Framework::Filesystem::VFSPath)
|
|
||||||
- MethodInvoker (Tesses::CrossLang::MethodInvoker)
|
|
||||||
- HeapObjects (Tesses::CrossLang::THeapObjectHolder)
|
|
||||||
@@ -19,31 +19,13 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <any>
|
#include <any>
|
||||||
|
|
||||||
/**
|
#include "CrossLangVersion.h"
|
||||||
* @brief CrossLang Runtime Major version
|
|
||||||
*
|
#define CROSSLANG_BYTECODE_MAJOR 1
|
||||||
*/
|
#define CROSSLANG_BYTECODE_MINOR 0
|
||||||
#define TVM_MAJOR 1
|
#define CROSSLANG_BYTECODE_PATCH 0
|
||||||
/**
|
#define CROSSLANG_BYTECODE_BUILD 0 //SHOULD ALWAYS BE 0
|
||||||
* @brief CrossLang Runtime Minor version
|
#define CROSSLANG_BYTECODE_VERSIONSTAGE DevVersion
|
||||||
*
|
|
||||||
*/
|
|
||||||
#define TVM_MINOR 0
|
|
||||||
/**
|
|
||||||
* @brief CrossLang Runtime Patch version
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#define TVM_PATCH 0
|
|
||||||
/**
|
|
||||||
* @brief CrossLang Runtime Build version
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#define TVM_BUILD 0
|
|
||||||
/**
|
|
||||||
* @brief CrossLang Runtime Stage version
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#define TVM_VERSIONSTAGE DevVersion
|
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
#undef Yield
|
#undef Yield
|
||||||
@@ -341,13 +323,13 @@ namespace Tesses::CrossLang {
|
|||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief Compares this to the runtime version
|
* @brief Compares this to the runtime version (for Bytecode)
|
||||||
*
|
*
|
||||||
* @return int CompareTo(RuntimeVersion) where RuntimeVersion is the runtime version
|
* @return int CompareTo(RuntimeVersion) where RuntimeVersion is the runtime version
|
||||||
*/
|
*/
|
||||||
int CompareToRuntime()
|
int CompareToRuntime()
|
||||||
{
|
{
|
||||||
TVMVersion version(TVM_MAJOR,TVM_MINOR,TVM_PATCH,TVM_BUILD,TVM_VERSIONSTAGE);
|
TVMVersion version(CROSSLANG_BYTECODE_MAJOR,CROSSLANG_BYTECODE_MINOR,CROSSLANG_BYTECODE_PATCH,CROSSLANG_BYTECODE_BUILD,CROSSLANG_BYTECODE_VERSIONSTAGE);
|
||||||
return CompareTo(version);
|
return CompareTo(version);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ namespace Tesses::CrossLang
|
|||||||
|
|
||||||
uint8_t main_header[18];
|
uint8_t main_header[18];
|
||||||
memcpy(main_header,"TCROSSVM",8);
|
memcpy(main_header,"TCROSSVM",8);
|
||||||
TVMVersion rtVersion(TVM_MAJOR,TVM_MINOR,TVM_PATCH,TVM_BUILD,TVM_VERSIONSTAGE);
|
TVMVersion rtVersion(CROSSLANG_BYTECODE_MAJOR,CROSSLANG_BYTECODE_MINOR,CROSSLANG_BYTECODE_PATCH,CROSSLANG_BYTECODE_BUILD,CROSSLANG_BYTECODE_VERSIONSTAGE);
|
||||||
rtVersion.ToArray(main_header+8);
|
rtVersion.ToArray(main_header+8);
|
||||||
version.ToArray(main_header+13);
|
version.ToArray(main_header+13);
|
||||||
strm->WriteBlock(main_header,sizeof(main_header));
|
strm->WriteBlock(main_header,sizeof(main_header));
|
||||||
|
|||||||
@@ -773,7 +773,7 @@ namespace Tesses::CrossLang {
|
|||||||
void Save(std::shared_ptr<Tesses::Framework::Filesystem::VFS> vfs, std::shared_ptr<Tesses::Framework::Streams::Stream> stream)
|
void Save(std::shared_ptr<Tesses::Framework::Filesystem::VFS> vfs, std::shared_ptr<Tesses::Framework::Streams::Stream> stream)
|
||||||
{
|
{
|
||||||
|
|
||||||
TVMVersion runtime_version(TVM_MAJOR,TVM_MINOR,TVM_PATCH,TVM_BUILD,TVM_VERSIONSTAGE);
|
TVMVersion runtime_version(CROSSLANG_BYTECODE_MAJOR,CROSSLANG_BYTECODE_MINOR,CROSSLANG_BYTECODE_PATCH,CROSSLANG_BYTECODE_BUILD,CROSSLANG_BYTECODE_VERSIONSTAGE);
|
||||||
uint8_t buffer[18];
|
uint8_t buffer[18];
|
||||||
memcpy(buffer,"TCROSSVM",8);
|
memcpy(buffer,"TCROSSVM",8);
|
||||||
runtime_version.ToArray(buffer+8);
|
runtime_version.ToArray(buffer+8);
|
||||||
|
|||||||
@@ -380,7 +380,7 @@ namespace Tesses::CrossLang
|
|||||||
|
|
||||||
void CodeGen::Save(std::shared_ptr<Tesses::Framework::Streams::Stream> stream)
|
void CodeGen::Save(std::shared_ptr<Tesses::Framework::Streams::Stream> stream)
|
||||||
{
|
{
|
||||||
TVMVersion runtime_version(TVM_MAJOR,TVM_MINOR,TVM_PATCH,TVM_BUILD,TVM_VERSIONSTAGE);
|
TVMVersion runtime_version(CROSSLANG_BYTECODE_MAJOR,CROSSLANG_BYTECODE_MINOR,CROSSLANG_BYTECODE_PATCH,CROSSLANG_BYTECODE_BUILD,CROSSLANG_BYTECODE_VERSIONSTAGE);
|
||||||
uint8_t buffer[18];
|
uint8_t buffer[18];
|
||||||
memcpy(buffer,"TCROSSVM",8);
|
memcpy(buffer,"TCROSSVM",8);
|
||||||
runtime_version.ToArray(buffer+8);
|
runtime_version.ToArray(buffer+8);
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ namespace Tesses::CrossLang
|
|||||||
|
|
||||||
std::string name = "Out";
|
std::string name = "Out";
|
||||||
std::vector<std::pair<std::string,std::string>> sources;
|
std::vector<std::pair<std::string,std::string>> sources;
|
||||||
TVMVersion version(TVM_MAJOR,TVM_MINOR,TVM_PATCH,TVM_BUILD,TVM_VERSIONSTAGE);
|
TVMVersion version(CROSSLANG_BYTECODE_MAJOR,CROSSLANG_BYTECODE_MINOR,CROSSLANG_BYTECODE_PATCH,CROSSLANG_BYTECODE_BUILD,CROSSLANG_BYTECODE_VERSIONSTAGE);
|
||||||
std::vector<std::pair<std::string,TVMVersion>> dependencies;
|
std::vector<std::pair<std::string,TVMVersion>> dependencies;
|
||||||
std::vector<std::pair<std::string,TVMVersion>> tools;
|
std::vector<std::pair<std::string,TVMVersion>> tools;
|
||||||
std::string info;
|
std::string info;
|
||||||
@@ -359,7 +359,10 @@ namespace Tesses::CrossLang
|
|||||||
|
|
||||||
dict->DeclareFunction(gc, "SourceToAst", "Convert source to ast", {"source"}, VM_SourceToAst);
|
dict->DeclareFunction(gc, "SourceToAst", "Convert source to ast", {"source"}, VM_SourceToAst);
|
||||||
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(CROSSLANG_MAJOR,CROSSLANG_MINOR,CROSSLANG_PATCH,0,TVMVersionStage::DevVersion);
|
||||||
|
});
|
||||||
|
dict->DeclareFunction(gc, "getBytecodeVersion","Get the bytecode version",{},[](GCList& ls,std::vector<TObject> args)->TObject {
|
||||||
|
return TVMVersion(CROSSLANG_BYTECODE_MAJOR,CROSSLANG_BYTECODE_MINOR,CROSSLANG_BYTECODE_PATCH,CROSSLANG_BYTECODE_BUILD,CROSSLANG_BYTECODE_VERSIONSTAGE);
|
||||||
});
|
});
|
||||||
dict->DeclareFunction(gc, "getIsRunning","Is the program still running",{},[](GCList& ls, std::vector<TObject> args)->TObject {
|
dict->DeclareFunction(gc, "getIsRunning","Is the program still running",{},[](GCList& ls, std::vector<TObject> args)->TObject {
|
||||||
return Tesses::Framework::TF_IsRunning();
|
return Tesses::Framework::TF_IsRunning();
|
||||||
|
|||||||
@@ -242,6 +242,7 @@ namespace Tesses::CrossLang
|
|||||||
break;
|
break;
|
||||||
case 11:
|
case 11:
|
||||||
{
|
{
|
||||||
|
|
||||||
auto data = parseEnt();
|
auto data = parseEnt();
|
||||||
TDictionary* dict;
|
TDictionary* dict;
|
||||||
if(GetObjectHeap(data,dict))
|
if(GetObjectHeap(data,dict))
|
||||||
|
|||||||
Reference in New Issue
Block a user